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