Geant4-11
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
HepGeom::Rotate3D Class Reference

#include <Transform3D.h>

Inheritance diagram for HepGeom::Rotate3D:
HepGeom::Transform3D HepGeom::RotateX3D HepGeom::RotateY3D HepGeom::RotateZ3D

Public Member Functions

double dx () const
 
double dy () const
 
double dz () const
 
void getDecomposition (Scale3D &scale, Rotate3D &rotation, Translate3D &translation) const
 
CLHEP::HepRotation getRotation () const
 
CLHEP::Hep3Vector getTranslation () const
 
Transform3D inverse () const
 
bool isNear (const Transform3D &t, double tolerance=2.2E-14) const
 
bool operator!= (const Transform3D &transform) const
 
double operator() (int, int) const
 
Transform3D operator* (const Transform3D &b) const
 
bool operator== (const Transform3D &transform) const
 
const Transform3D_row operator[] (int) const
 
 Rotate3D ()
 
 Rotate3D (const CLHEP::HepRotation &mt)
 
 Rotate3D (const Point3D< double > &fr1, const Point3D< double > &fr2, const Point3D< double > &to1, const Point3D< double > &to2)
 
 Rotate3D (double a, const Point3D< double > &p1, const Point3D< double > &p2)
 
 Rotate3D (double a, const Vector3D< double > &v)
 
void setIdentity ()
 
double xx () const
 
double xy () const
 
double xz () const
 
double yx () const
 
double yy () const
 
double yz () const
 
double zx () const
 
double zy () const
 
double zz () const
 

Static Public Attributes

static DLL_API const Transform3D Identity = Transform3D ()
 

Protected Member Functions

void setTransform (double XX, double XY, double XZ, double DX, double YX, double YY, double YZ, double DY, double ZX, double ZY, double ZZ, double DZ)
 

Protected Attributes

double dx_
 
double dy_
 
double dz_
 
double xx_
 
double xy_
 
double xz_
 
double yx_
 
double yy_
 
double yz_
 
double zx_
 
double zy_
 
double zz_
 

Detailed Description

Constructs a rotation transformation. This class provides additional constructors for Transform3D and should not be used as a separate class.

Example of use:

m = Rotate3D(30.*deg, HepVector3D(1.,1.,1.));
static constexpr double m
Definition: G4SIunits.hh:109
static constexpr double deg
Definition: G4SIunits.hh:132
Author
Evgue.nosp@m.ni.T.nosp@m.chern.nosp@m.iaev.nosp@m.@cern.nosp@m..ch

Definition at line 370 of file Transform3D.h.

Constructor & Destructor Documentation

◆ Rotate3D() [1/5]

HepGeom::Rotate3D::Rotate3D ( )
inline

Default constructor: sets the Identity transformation.

Definition at line 374 of file Transform3D.h.

374: Transform3D() {}

◆ Rotate3D() [2/5]

HepGeom::Rotate3D::Rotate3D ( const CLHEP::HepRotation mt)
inline

Constructor from CLHEP::HepRotation.

◆ Rotate3D() [3/5]

HepGeom::Rotate3D::Rotate3D ( double  a,
const Point3D< double > &  p1,
const Point3D< double > &  p2 
)

Constructor from angle and axis given by two points.

Parameters
aangle of rotation
p1begin point of the axis
p2end point of the axis

Definition at line 230 of file Transform3D.cc.

232 : Transform3D()
233 /***********************************************************************
234 * *
235 * Name: Rotate3D::Rotate3D Date: 24.09.96 *
236 * Author: E.Chernyaev (IHEP/Protvino) Revised: *
237 * *
238 * Function: Create 3D Rotation through angle "a" (counterclockwise) *
239 * around the axis p1->p2 *
240 * *
241 ***********************************************************************/
242 {
243 if (a == 0) return;
244
245 double cx = p2.x()-p1.x(), cy = p2.y()-p1.y(), cz = p2.z()-p1.z();
246 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
247 if (ll == 0) {
248 std::cerr << "Rotate3D: zero axis" << std::endl;
249 }else{
250 double cosa = std::cos(a), sina = std::sin(a);
251 cx /= ll; cy /= ll; cz /= ll;
252
253 double txx = cosa + (1-cosa)*cx*cx;
254 double txy = (1-cosa)*cx*cy - sina*cz;
255 double txz = (1-cosa)*cx*cz + sina*cy;
256
257 double tyx = (1-cosa)*cy*cx + sina*cz;
258 double tyy = cosa + (1-cosa)*cy*cy;
259 double tyz = (1-cosa)*cy*cz - sina*cx;
260
261 double tzx = (1-cosa)*cz*cx - sina*cy;
262 double tzy = (1-cosa)*cz*cy + sina*cx;
263 double tzz = cosa + (1-cosa)*cz*cz;
264
265 double tdx = p1.x(), tdy = p1.y(), tdz = p1.z();
266
267 setTransform(txx, txy, txz, tdx-txx*tdx-txy*tdy-txz*tdz,
268 tyx, tyy, tyz, tdy-tyx*tdx-tyy*tdy-tyz*tdz,
269 tzx, tzy, tzz, tdz-tzx*tdx-tzy*tdy-tzz*tdz);
270 }
271 }
void setTransform(double XX, double XY, double XZ, double DX, double YX, double YY, double YZ, double DY, double ZX, double ZY, double ZZ, double DZ)
Definition: Transform3D.h:185

References HepGeom::Transform3D::setTransform(), HepGeom::BasicVector3D< T >::x(), HepGeom::BasicVector3D< T >::y(), and HepGeom::BasicVector3D< T >::z().

◆ Rotate3D() [4/5]

HepGeom::Rotate3D::Rotate3D ( double  a,
const Vector3D< double > &  v 
)
inline

Constructor from angle and axis.

Parameters
aangle of rotation
vaxis of rotation

◆ Rotate3D() [5/5]

HepGeom::Rotate3D::Rotate3D ( const Point3D< double > &  fr1,
const Point3D< double > &  fr2,
const Point3D< double > &  to1,
const Point3D< double > &  to2 
)
inline

Constructor for rotation given by original and rotated position of two points. It is assumed that there is no reflection.

Parameters
fr1original position of 1st point
fr2original position of 2nd point
to1rotated position of 1st point
to2rotated position of 2nd point

Member Function Documentation

◆ dx()

double HepGeom::Transform3D::dx ( ) const
inlineinherited

◆ dy()

double HepGeom::Transform3D::dy ( ) const
inlineinherited

◆ dz()

double HepGeom::Transform3D::dz ( ) const
inlineinherited

◆ getDecomposition()

void HepGeom::Transform3D::getDecomposition ( Scale3D scale,
Rotate3D rotation,
Translate3D translation 
) const
inherited

Decomposition of general transformation. This function gets decomposition of the transformation in three consequentive specific transformations: Scale3D, then Rotate3D, then Translate3, i.e.

Transform3D = Translate3D * Rotate3D * Scale3D
Parameters
scaleoutput: scaling transformation; if there was a reflection, then scale factor for z-component (scale(2,2)) will be negative.
rotationoutput: rotation transformaion.
translationoutput: translation transformaion.

Definition at line 173 of file Transform3D.cc.

187 {
188 double sx = std::sqrt(xx_*xx_ + yx_*yx_ + zx_*zx_);
189 double sy = std::sqrt(xy_*xy_ + yy_*yy_ + zy_*zy_);
190 double sz = std::sqrt(xz_*xz_ + yz_*yz_ + zz_*zz_);
191
192 if (xx_*(yy_*zz_-yz_*zy_) -
193 xy_*(yx_*zz_-yz_*zx_) +
194 xz_*(yx_*zy_-yy_*zx_) < 0) sz = -sz;
195 scale.setTransform(sx,0,0,0, 0,sy,0,0, 0,0,sz,0);
196 rotation.setTransform(xx_/sx,xy_/sy,xz_/sz,0,
197 yx_/sx,yy_/sy,yz_/sz,0,
198 zx_/sx,zy_/sy,zz_/sz,0);
199 translation.setTransform(1,0,0,dx_, 0,1,0,dy_, 0,0,1,dz_);
200 }

Referenced by G4AssemblyVolume::AddPlacedAssembly(), G4AssemblyVolume::AddPlacedVolume(), G4PhysicalVolumeModel::DescribeAndDescend(), G4MultiUnion::GetGlobalVector(), G4MultiUnion::GetLocalVector(), operator<<(), G4GDMLWriteStructure::PhysvolWrite(), G4ReflectionFactory::Place(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ getRotation()

CLHEP::HepRotation HepGeom::Transform3D::getRotation ( ) const
inlineinherited

◆ getTranslation()

CLHEP::Hep3Vector HepGeom::Transform3D::getTranslation ( ) const
inlineinherited

◆ inverse()

Transform3D HepGeom::Transform3D::inverse ( ) const
inherited

Returns the inverse transformation.

Definition at line 141 of file Transform3D.cc.

150 {
151 double detxx = yy_*zz_-yz_*zy_;
152 double detxy = yx_*zz_-yz_*zx_;
153 double detxz = yx_*zy_-yy_*zx_;
154 double det = xx_*detxx - xy_*detxy + xz_*detxz;
155 if (det == 0) {
156 std::cerr << "Transform3D::inverse error: zero determinant" << std::endl;
157 return Transform3D();
158 }
159 det = 1./det; detxx *= det; detxy *= det; detxz *= det;
160 double detyx = (xy_*zz_ - xz_*zy_)*det;
161 double detyy = (xx_*zz_ - xz_*zx_)*det;
162 double detyz = (xx_*zy_ - xy_*zx_)*det;
163 double detzx = (xy_*yz_ - xz_*yy_)*det;
164 double detzy = (xx_*yz_ - xz_*yx_)*det;
165 double detzz = (xx_*yy_ - xy_*yx_)*det;
166 return Transform3D
167 (detxx, -detyx, detzx, -detxx*dx_+detyx*dy_-detzx*dz_,
168 -detxy, detyy, -detzy, detxy*dx_-detyy*dy_+detzy*dz_,
169 detxz, -detyz, detzz, -detxz*dx_+detyz*dy_-detzz*dz_);
170 }

References HepGeom::Transform3D::dx_, HepGeom::Transform3D::dy_, HepGeom::Transform3D::dz_, HepGeom::Transform3D::Transform3D(), HepGeom::Transform3D::xx_, HepGeom::Transform3D::xy_, HepGeom::Transform3D::xz_, HepGeom::Transform3D::yx_, HepGeom::Transform3D::yy_, HepGeom::Transform3D::yz_, HepGeom::Transform3D::zx_, HepGeom::Transform3D::zy_, and HepGeom::Transform3D::zz_.

Referenced by G4VtkSceneHandler::AddPrimitiveTensorGlyph(), G4PhysicalVolumeModel::DescribeAndDescend(), G4PhysicalVolumeModel::DescribeSolid(), G4ScoringBox::Draw(), G4ScoringCylinder::Draw(), G4ScoringBox::DrawColumn(), G4ScoringCylinder::DrawColumn(), G4GMocrenFileSceneHandler::ExtractDetector(), G3toG4BuildPVTree(), G4MultiUnion::GetLocalPoint(), G4MultiUnion::GetLocalVector(), G4ReflectedSolid::GetTransform3D(), GetTransform3D(), G4ReflectionFactory::Place(), G4ReflectionFactory::ReflectPVPlacement(), SubstractSolids(), and G4GDMLWriteStructure::TraverseVolumeTree().

◆ isNear()

bool HepGeom::Transform3D::isNear ( const Transform3D t,
double  tolerance = 2.2E-14 
) const
inherited

Returns true if the difference between corresponding matrix elements is less than the tolerance.

Definition at line 203 of file Transform3D.cc.

204 {
205 return ( (std::abs(xx_ - t.xx_) <= tolerance) &&
206 (std::abs(xy_ - t.xy_) <= tolerance) &&
207 (std::abs(xz_ - t.xz_) <= tolerance) &&
208 (std::abs(dx_ - t.dx_) <= tolerance) &&
209 (std::abs(yx_ - t.yx_) <= tolerance) &&
210 (std::abs(yy_ - t.yy_) <= tolerance) &&
211 (std::abs(yz_ - t.yz_) <= tolerance) &&
212 (std::abs(dy_ - t.dy_) <= tolerance) &&
213 (std::abs(zx_ - t.zx_) <= tolerance) &&
214 (std::abs(zy_ - t.zy_) <= tolerance) &&
215 (std::abs(zz_ - t.zz_) <= tolerance) &&
216 (std::abs(dz_ - t.dz_) <= tolerance) );
217 }

References HepGeom::Transform3D::dx_, HepGeom::Transform3D::dy_, HepGeom::Transform3D::dz_, HepGeom::Transform3D::xx_, HepGeom::Transform3D::xy_, HepGeom::Transform3D::xz_, HepGeom::Transform3D::yx_, HepGeom::Transform3D::yy_, HepGeom::Transform3D::yz_, HepGeom::Transform3D::zx_, HepGeom::Transform3D::zy_, and HepGeom::Transform3D::zz_.

◆ operator!=()

bool HepGeom::Transform3D::operator!= ( const Transform3D transform) const
inlineinherited

Test for inequality.

Definition at line 349 of file Transform3D.h.

349 {
350 return ! operator==(transform);
351 }
bool operator==(const Transform3D &transform) const
Definition: Transform3D.cc:220
G4bool transform(G4String &input, const G4String &type)

References HepGeom::Transform3D::operator==(), and G4coutFormatters::anonymous_namespace{G4coutFormatters.cc}::transform().

◆ operator()()

double HepGeom::Transform3D::operator() ( int  i,
int  j 
) const
inherited

Fortran-style subscripting: returns (i,j) element of the matrix.

Definition at line 23 of file Transform3D.cc.

23 {
24 if (i == 0) {
25 if (j == 0) { return xx_; }
26 if (j == 1) { return xy_; }
27 if (j == 2) { return xz_; }
28 if (j == 3) { return dx_; }
29 } else if (i == 1) {
30 if (j == 0) { return yx_; }
31 if (j == 1) { return yy_; }
32 if (j == 2) { return yz_; }
33 if (j == 3) { return dy_; }
34 } else if (i == 2) {
35 if (j == 0) { return zx_; }
36 if (j == 1) { return zy_; }
37 if (j == 2) { return zz_; }
38 if (j == 3) { return dz_; }
39 } else if (i == 3) {
40 if (j == 0) { return 0.0; }
41 if (j == 1) { return 0.0; }
42 if (j == 2) { return 0.0; }
43 if (j == 3) { return 1.0; }
44 }
45 std::cerr << "Transform3D subscripting: bad indices "
46 << "(" << i << "," << j << ")" << std::endl;
47 return 0.0;
48 }

References HepGeom::Transform3D::dx_, HepGeom::Transform3D::dy_, HepGeom::Transform3D::dz_, HepGeom::Transform3D::xx_, HepGeom::Transform3D::xy_, HepGeom::Transform3D::xz_, HepGeom::Transform3D::yx_, HepGeom::Transform3D::yy_, HepGeom::Transform3D::yz_, HepGeom::Transform3D::zx_, HepGeom::Transform3D::zy_, and HepGeom::Transform3D::zz_.

◆ operator*()

Transform3D HepGeom::Transform3D::operator* ( const Transform3D b) const
inherited

Transformation by another Transform3D.

Definition at line 51 of file Transform3D.cc.

51 {
52 return Transform3D
53 (xx_*b.xx_+xy_*b.yx_+xz_*b.zx_, xx_*b.xy_+xy_*b.yy_+xz_*b.zy_,
54 xx_*b.xz_+xy_*b.yz_+xz_*b.zz_, xx_*b.dx_+xy_*b.dy_+xz_*b.dz_+dx_,
55 yx_*b.xx_+yy_*b.yx_+yz_*b.zx_, yx_*b.xy_+yy_*b.yy_+yz_*b.zy_,
56 yx_*b.xz_+yy_*b.yz_+yz_*b.zz_, yx_*b.dx_+yy_*b.dy_+yz_*b.dz_+dy_,
57 zx_*b.xx_+zy_*b.yx_+zz_*b.zx_, zx_*b.xy_+zy_*b.yy_+zz_*b.zy_,
58 zx_*b.xz_+zy_*b.yz_+zz_*b.zz_, zx_*b.dx_+zy_*b.dy_+zz_*b.dz_+dz_);
59 }

References HepGeom::Transform3D::dx_, HepGeom::Transform3D::dy_, HepGeom::Transform3D::dz_, HepGeom::Transform3D::Transform3D(), HepGeom::Transform3D::xx_, HepGeom::Transform3D::xy_, HepGeom::Transform3D::xz_, HepGeom::Transform3D::yx_, HepGeom::Transform3D::yy_, HepGeom::Transform3D::yz_, HepGeom::Transform3D::zx_, HepGeom::Transform3D::zy_, and HepGeom::Transform3D::zz_.

◆ operator==()

bool HepGeom::Transform3D::operator== ( const Transform3D transform) const
inherited

Test for equality.

Definition at line 220 of file Transform3D.cc.

221 {
222 return (this == &t) ? true :
223 (xx_==t.xx_ && xy_==t.xy_ && xz_==t.xz_ && dx_==t.dx_ &&
224 yx_==t.yx_ && yy_==t.yy_ && yz_==t.yz_ && dy_==t.dy_ &&
225 zx_==t.zx_ && zy_==t.zy_ && zz_==t.zz_ && dz_==t.dz_ );
226 }

References HepGeom::Transform3D::dx_, HepGeom::Transform3D::dy_, HepGeom::Transform3D::dz_, HepGeom::Transform3D::xx_, HepGeom::Transform3D::xy_, HepGeom::Transform3D::xz_, HepGeom::Transform3D::yx_, HepGeom::Transform3D::yy_, HepGeom::Transform3D::yz_, HepGeom::Transform3D::zx_, HepGeom::Transform3D::zy_, and HepGeom::Transform3D::zz_.

Referenced by HepGeom::Transform3D::operator!=().

◆ operator[]()

const Transform3D_row HepGeom::Transform3D::operator[] ( int  ) const
inlineinherited

Returns object of the helper class for C-style subscripting r[i][j]

◆ setIdentity()

void HepGeom::Transform3D::setIdentity ( )
inlineinherited

◆ setTransform()

void HepGeom::Transform3D::setTransform ( double  XX,
double  XY,
double  XZ,
double  DX,
double  YX,
double  YY,
double  YZ,
double  DY,
double  ZX,
double  ZY,
double  ZZ,
double  DZ 
)
inlineprotectedinherited

◆ xx()

double HepGeom::Transform3D::xx ( ) const
inlineinherited

◆ xy()

double HepGeom::Transform3D::xy ( ) const
inlineinherited

◆ xz()

double HepGeom::Transform3D::xz ( ) const
inlineinherited

◆ yx()

double HepGeom::Transform3D::yx ( ) const
inlineinherited

◆ yy()

double HepGeom::Transform3D::yy ( ) const
inlineinherited

◆ yz()

double HepGeom::Transform3D::yz ( ) const
inlineinherited

◆ zx()

double HepGeom::Transform3D::zx ( ) const
inlineinherited

◆ zy()

double HepGeom::Transform3D::zy ( ) const
inlineinherited

◆ zz()

double HepGeom::Transform3D::zz ( ) const
inlineinherited

Field Documentation

◆ dx_

double HepGeom::Transform3D::dx_
protectedinherited

◆ dy_

double HepGeom::Transform3D::dy_
protectedinherited

◆ dz_

double HepGeom::Transform3D::dz_
protectedinherited

◆ Identity

const Transform3D HepGeom::Transform3D::Identity = Transform3D ()
staticinherited

Global identity transformation.

Definition at line 196 of file Transform3D.h.

Referenced by G4GMocrenFileSceneHandler::Detector::clear(), G4GDMLWriteStructure::TraverseVolumeTree(), and G4GDMLWrite::Write().

◆ xx_

double HepGeom::Transform3D::xx_
protectedinherited

◆ xy_

double HepGeom::Transform3D::xy_
protectedinherited

◆ xz_

double HepGeom::Transform3D::xz_
protectedinherited

◆ yx_

double HepGeom::Transform3D::yx_
protectedinherited

◆ yy_

double HepGeom::Transform3D::yy_
protectedinherited

◆ yz_

double HepGeom::Transform3D::yz_
protectedinherited

◆ zx_

double HepGeom::Transform3D::zx_
protectedinherited

◆ zy_

double HepGeom::Transform3D::zy_
protectedinherited

◆ zz_

double HepGeom::Transform3D::zz_
protectedinherited

The documentation for this class was generated from the following files: