Geant4  10.00.p01
Transform3D.icc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id:$
3 // ---------------------------------------------------------------------------
4 
5 #include "CLHEP/Vector/ThreeVector.h"
6 #include "CLHEP/Vector/Rotation.h"
7 #include "CLHEP/Geometry/Point3D.h"
8 #include "CLHEP/Geometry/Vector3D.h"
9 #include "CLHEP/Geometry/Normal3D.h"
10 
11 namespace HepGeom {
12 
13 // I N L I N E S F O R T R A N S F O R M A T I O N
14 
15 inline
16 Transform3D::Transform3D_row::Transform3D_row
17 (const Transform3D & r, int i) : rr(r), ii(i) {}
18 
19 inline
20 double Transform3D::Transform3D_row::operator[](int jj) const {
21  return rr(ii,jj);
22 }
23 
24 inline
25 const Transform3D::Transform3D_row Transform3D::operator[](int i) const {
26  return Transform3D_row(*this, i);
27 }
28 
29 inline
30 Transform3D::Transform3D(const CLHEP::HepRotation & m, const CLHEP::Hep3Vector & v) {
31  xx_= m.xx(); xy_= m.xy(); xz_= m.xz();
32  yx_= m.yx(); yy_= m.yy(); yz_= m.yz();
33  zx_= m.zx(); zy_= m.zy(); zz_= m.zz();
34  dx_= v.x(); dy_= v.y(); dz_= v.z();
35 }
36 
37 inline
38 CLHEP::HepRotation
39 Transform3D::getRotation() const {
40  CLHEP::HepRotation m;
41  return m.rotateAxes(CLHEP::Hep3Vector(xx_,yx_,zx_),
42  CLHEP::Hep3Vector(xy_,yy_,zy_),
43  CLHEP::Hep3Vector(xz_,yz_,zz_));
44 }
45 
46 inline
47 CLHEP::Hep3Vector
48 Transform3D::getTranslation() const {
49  return CLHEP::Hep3Vector(dx_,dy_,dz_);
50 }
51 
52 // I N L I N E S F O R R O T A T I O N
53 
54 inline
55 Rotate3D::Rotate3D(const CLHEP::HepRotation & m) {
56  xx_= m.xx(); xy_= m.xy(); xz_= m.xz();
57  yx_= m.yx(); yy_= m.yy(); yz_= m.yz();
58  zx_= m.zx(); zy_= m.zy(); zz_= m.zz();
59  dx_= 0; dy_= 0; dz_= 0;
60 }
61 
62 inline
63 Rotate3D::Rotate3D(double a, const Vector3D<double> & v) {
64  *this =
65  Rotate3D(a, Point3D<double>(0,0,0), Point3D<double>(v.x(),v.y(),v.z()));
66 }
67 
68 inline
69 Rotate3D::Rotate3D(const Point3D<double> & fr1, const Point3D<double> & fr2,
70  const Point3D<double> & to1, const Point3D<double> & to2)
71  : Transform3D(Point3D<double>(0,0,0),fr1,fr2,
72  Point3D<double>(0,0,0),to1,to2) {}
73 
74 // I N L I N E S F O R T R A N S L A T I O N
75 
76 inline
77 Translate3D::Translate3D(const CLHEP::Hep3Vector & v)
78  : Transform3D(1,0,0,v.x(), 0,1,0,v.y(), 0,0,1,v.z()) {}
79 
80 // I N L I N E S F O R R E F L E C T I O N
81 
82 inline
83 Reflect3D::Reflect3D(const Normal3D<double> & n, const Point3D<double> & p) {
84  *this = Reflect3D(n.x(), n.y(), n.z(), -n*p);
85 }
86 
87 } /* namespace HepGeom */