#include <BLCoordinateTransform.hh>
An object is first defined in its local coordinates (i.e. with the beam centerline along +Z). The object is rotated in place, and is then translated to position. That's how the constructors work; the actual transformation goes the other way. And normally the transform of each group is applied to the transforms of its elements, so each placed element's transform goes global->local in one fell swoop.
This class is completely inline.
Public Member Functions | |
BLCoordinateTransform () | |
Default constructor. Identity transformation. | |
BLCoordinateTransform (const G4ThreeVector &pos) | |
Constructor for a simple unrotated position. pos is the parent location of the object. | |
BLCoordinateTransform (const G4RotationMatrix &rot, const G4ThreeVector &pos) | |
Constructor for a rotation and position. | |
BLCoordinateTransform (const G4RotationMatrix *rot, const G4ThreeVector &pos) | |
Constructor for a rotation and position. | |
void | getLocal (G4double local[4], const G4double global[4]) const |
getLocal() - get local coordinates from global coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") Both arguments can be the same 4-vector (Point); the time coord is unchanged. | |
void | getLocal (G4ThreeVector &local, const G4ThreeVector &global) const |
getLocal() - get local coordinates from global coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") The two arguments should NOT be the same. | |
void | getGlobal (const G4double local[4], G4double global[4]) const |
getGlobal() - get Global coordinates from local coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") Both arguments can be the same 4-vector (Point); the time coord is unchanged. | |
void | getGlobal (const G4ThreeVector &local, G4ThreeVector &global) const |
getGlobal() - get global coordinates from local coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") The two arguments should NOT be the same. | |
void | apply (const BLCoordinateTransform &parentTransform) |
apply() will apply a BLCoordinateTransform to this one. This function is used to apply the transform for a parent to objects placed into the parent group -- the objects' rotations and positions are specified wrt the parent in the parent's local coordinates. This routine should be called during construction, not during tracking (it inverts a matrix). | |
G4ThreeVector & | getPosition () |
getPosition() returns the position of the transform. | |
G4RotationMatrix & | getRotation () |
getRotation() returns the Rotation of the transform. | |
G4RotationMatrix & | getRotationInverse () |
getRotationInverse() returns the inverse Rotation of the transform (this is the active rotation of the object). OK to use during tracking (the inverse is computed just once). | |
G4bool | isRotated () const |
isRotated() returns true iff this transformation includes rotation. | |
Private Member Functions | |
void | checkRotation () |
for efficiency in un-rotated xforms | |
Private Attributes | |
G4RotationMatrix | rot_p2l |
G4RotationMatrix | rot_l2p |
rotation parent->local | |
G4ThreeVector | position |
rotation local->parent | |
G4bool | rotated |
parent position of local (0,0,0) |
BLCoordinateTransform::BLCoordinateTransform | ( | ) | [inline] |
BLCoordinateTransform::BLCoordinateTransform | ( | const G4ThreeVector & | pos | ) | [inline] |
BLCoordinateTransform::BLCoordinateTransform | ( | const G4RotationMatrix & | rot, | |
const G4ThreeVector & | pos | |||
) | [inline] |
Constructor for a rotation and position.
References checkRotation(), and rot_p2l.
00078 : 00079 rot_p2l(rot), rot_l2p(rot), 00080 position(pos), rotated(false) 00081 { rot_p2l.invert(); checkRotation(); }
BLCoordinateTransform::BLCoordinateTransform | ( | const G4RotationMatrix * | rot, | |
const G4ThreeVector & | pos | |||
) | [inline] |
void BLCoordinateTransform::checkRotation | ( | ) | [inline, private] |
for efficiency in un-rotated xforms
References rot_p2l, and rotated.
Referenced by apply(), and BLCoordinateTransform().
00054 { 00055 // two test vectors is enough 00056 G4ThreeVector x(1.0,0.0,0.0), y(0.0,1.0,0.0); 00057 x = rot_p2l * x; 00058 y = rot_p2l * y; 00059 if(fabs(y[0]) > 1e-8 || fabs(y[1]-1.0) > 1e-8 || 00060 fabs(y[2]) > 1e-8 || fabs(x[0]-1.0) > 1e-8 || 00061 fabs(x[1]) > 1e-8 || fabs(x[2]) > 1e-8) 00062 rotated = true; 00063 else 00064 rotated = false; 00065 }
void BLCoordinateTransform::getLocal | ( | G4double | local[4], | |
const G4double | global[4] | |||
) | const [inline] |
getLocal() - get local coordinates from global coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") Both arguments can be the same 4-vector (Point); the time coord is unchanged.
Referenced by SolenoidField::addFieldValue(), RFdeviceField::addFieldValue(), PillboxField::addFieldValue(), MultipoleField::addFieldValue(), LiLensField::addFieldValue(), IdealSectorBendField::addFieldValue(), HelicalHarmonicField::addFieldValue(), HelicalDipoleField::addFieldValue(), GenericQuadField::addFieldValue(), GenericBendField::addFieldValue(), FieldMapPlacement::addFieldValue(), FieldExprPlacement::addFieldValue(), and BLCoordinates::getCoords().
00097 { 00098 G4ThreeVector l, g; //@@ can probably optimize this.... 00099 g[0] = global[0]; 00100 g[1] = global[1]; 00101 g[2] = global[2]; 00102 getLocal(l,g); 00103 local[0] = l[0]; 00104 local[1] = l[1]; 00105 local[2] = l[2]; 00106 local[3] = global[3]; 00107 }
void BLCoordinateTransform::getLocal | ( | G4ThreeVector & | local, | |
const G4ThreeVector & | global | |||
) | const [inline] |
getLocal() - get local coordinates from global coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") The two arguments should NOT be the same.
References position, rot_p2l, and rotated.
00115 { 00116 if(rotated) 00117 local = rot_p2l * (global - position); 00118 else 00119 local = global - position; 00120 }
void BLCoordinateTransform::getGlobal | ( | const G4double | local[4], | |
G4double | global[4] | |||
) | const [inline] |
getGlobal() - get Global coordinates from local coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") Both arguments can be the same 4-vector (Point); the time coord is unchanged.
Referenced by BLCMDhelicalharmonic::EndOfRunAction(), BLCMDhelicaldipole::EndOfRunAction(), FieldExprPlacement::FieldExprPlacement(), FieldMapPlacement::FieldMapPlacement(), GenericBendField::GenericBendField(), GenericQuadField::GenericQuadField(), HelicalDipoleField::HelicalDipoleField(), HelicalHarmonicField::HelicalHarmonicField(), MultipoleField::MultipoleField(), PillboxField::PillboxField(), RFdeviceField::RFdeviceField(), and SolenoidField::SolenoidField().
00128 { 00129 G4ThreeVector l, g; //@@ can probably optimize this.... 00130 l[0] = local[0]; 00131 l[1] = local[1]; 00132 l[2] = local[2]; 00133 getGlobal(l,g); 00134 global[0] = g[0]; 00135 global[1] = g[1]; 00136 global[2] = g[2]; 00137 global[3] = local[3]; 00138 }
void BLCoordinateTransform::getGlobal | ( | const G4ThreeVector & | local, | |
G4ThreeVector & | global | |||
) | const [inline] |
getGlobal() - get global coordinates from local coordinates. This assumes that the BLCoordinateTransform transform for each enclosing group has been applied (in descending order). (otherwise "global" is really just "parent") The two arguments should NOT be the same.
References position, rot_l2p, and rotated.
00146 { 00147 if(rotated) 00148 global = rot_l2p * local + position; 00149 else 00150 global = local + position; 00151 }
void BLCoordinateTransform::apply | ( | const BLCoordinateTransform & | parentTransform | ) | [inline] |
apply() will apply a BLCoordinateTransform to this one. This function is used to apply the transform for a parent to objects placed into the parent group -- the objects' rotations and positions are specified wrt the parent in the parent's local coordinates. This routine should be called during construction, not during tracking (it inverts a matrix).
References checkRotation(), position, rot_l2p, rot_p2l, and rotated.
00159 { 00160 if(parentTransform.rotated) { 00161 position = parentTransform.rot_l2p * position + 00162 parentTransform.position; 00163 if(rotated) 00164 rot_p2l = rot_p2l * parentTransform.rot_p2l; 00165 else 00166 rot_p2l = parentTransform.rot_p2l; 00167 rot_l2p = rot_p2l; 00168 rot_l2p.invert(); 00169 } else { 00170 position += parentTransform.position; 00171 } 00172 checkRotation(); 00173 }
G4ThreeVector& BLCoordinateTransform::getPosition | ( | ) | [inline] |
getPosition() returns the position of the transform.
References position.
Referenced by BLCMDsolenoid::construct(), BLCMDrfdevice::construct(), and BLCMDpillbox::construct().
00176 { return position; }
G4RotationMatrix& BLCoordinateTransform::getRotation | ( | ) | [inline] |
getRotation() returns the Rotation of the transform.
References rot_p2l.
Referenced by FieldExprPlacement::FieldExprPlacement(), FieldMapPlacement::FieldMapPlacement(), GenericBendField::GenericBendField(), GenericQuadField::GenericQuadField(), BLCoordinates::getCoords(), BLCoordinates::getRotation(), HelicalDipoleField::HelicalDipoleField(), HelicalHarmonicField::HelicalHarmonicField(), IdealSectorBendField::IdealSectorBendField(), LiLensField::LiLensField(), MultipoleField::MultipoleField(), PillboxField::PillboxField(), RFdeviceField::RFdeviceField(), and SolenoidField::SolenoidField().
00179 { return rot_p2l; }
G4RotationMatrix& BLCoordinateTransform::getRotationInverse | ( | ) | [inline] |
getRotationInverse() returns the inverse Rotation of the transform (this is the active rotation of the object). OK to use during tracking (the inverse is computed just once).
References rot_l2p.
00184 { return rot_l2p; }
G4bool BLCoordinateTransform::isRotated | ( | ) | const [inline] |
isRotated() returns true iff this transformation includes rotation.
References rotated.
Referenced by MultipoleField::addFieldValue(), IdealSectorBendField::addFieldValue(), HelicalHarmonicField::addFieldValue(), HelicalDipoleField::addFieldValue(), GenericQuadField::addFieldValue(), GenericBendField::addFieldValue(), BLCMDrfdevice::construct(), BLCMDpillbox::construct(), FieldExprPlacement::FieldExprPlacement(), FieldMapPlacement::FieldMapPlacement(), LiLensField::LiLensField(), PillboxField::PillboxField(), RFdeviceField::RFdeviceField(), and SolenoidField::SolenoidField().
00187 { return rotated; }
G4RotationMatrix BLCoordinateTransform::rot_p2l [private] |
Referenced by apply(), BLCoordinateTransform(), checkRotation(), getLocal(), and getRotation().
G4RotationMatrix BLCoordinateTransform::rot_l2p [private] |
rotation parent->local
Referenced by apply(), BLCoordinateTransform(), getGlobal(), and getRotationInverse().
G4ThreeVector BLCoordinateTransform::position [private] |
G4bool BLCoordinateTransform::rotated [private] |
parent position of local (0,0,0)
Referenced by apply(), checkRotation(), getGlobal(), getLocal(), and isRotated().