// lt-4.cc // A ZOOM PhysicsVectors tutorial example // // Tutorial example 4 for the LorentzTransformation class: // // LorentzBoosts Along a Coordinate Axis // // * Constructing Coordinate Axis Boosts // * Components of the matrix representaton // * Multiplication and inversion // * Comparisons // Key lines are marked by // <------------- // Get the LorentzTransformation class #include "ZMutility/ZMenvironment.h" #include "PhysicsVectors/LorentzTransformation.h" ZM_USING_NAMESPACE( zmpv ) USING( std::cout ) USING( std::endl ) // These classes themselves pull in FixedTypes, but just to // remind ourselves that we are using Float8, not double, for // 64-bit floats... #include "ZMutility/FixedTypes.h" ZM_USING_NAMESPACE( zmfxt ) // This example will use iostream output, so get that -- // in a portable way. #include "ZMutility/iostream" using std::cout; using std::endl; // This example also tries to make the afore-mentioned output // a bit more readable: #include "ZMutility/iomanip" using std::setw; int main() { // ***** Constructing Coordinate Axis Boosts // Here is how to construct a LorentzBoostZ from a value beta: //------------------------------------------------------------ cout << "Constructing bz1 from beta \n"; Float8 beta = .75; LorentzBoostZ bz1( beta ); // <------------- cout << "bz1 = " << bz1 << endl; // The same applies for X, Y, and Z boosts // ***** Components of the matrix representation // Here is how to obtain a 4x4 matrix representation: //--------------------------------------------------- ZMpvRep4x4 m_rep = bz1.rep4x4(); // <------------- cout << setw(15) << m_rep.xx_ << setw(15) << m_rep.xy_ << setw(15) << m_rep.xz_ << setw(15) << m_rep.xt_ << endl; cout << setw(15) << m_rep.yx_ << setw(15) << m_rep.yy_ << setw(15) << m_rep.yz_ << setw(15) << m_rep.yt_ << endl; cout << setw(15) << m_rep.zx_ << setw(15) << m_rep.zy_ << setw(15) << m_rep.zz_ << setw(15) << m_rep.zt_ << endl; cout << setw(15) << m_rep.tx_ << setw(15) << m_rep.ty_ << setw(15) << m_rep.tz_ << setw(15) << m_rep.tt_ << endl << endl; // Here is how to obtain individual matrix elements: //-------------------------------------------------- LorentzBoostY by1 (.51); cout << "by1's matrix elements: \n"; cout << "xx = " << by1.xx() // <------------- << ", xy = " << by1.xy() << ", xz = " << by1.xz() << ", xt = " << by1.xt() << ", etc. " << endl; // ***** Multiplication and Inversion // Here is how to mutliply Axis Boosts: //------------------------------------- LorentzBoostX bx1( .54 ); LorentzBoostX bx2( .45 ); LorentzBoostX bx3 = bx1 * bx2; // <------------- cout << "bx3 = bx1*bx2 = " << bx3 << endl; // Multiply and assign works as well: //bx3 *= bx1; // <------------- bx3 = bx3 * bx1; // <------------- cout << "bx3 now = " << bx3 << endl; // Here is how to multiply Axis Boosts to give a generic Boost: //------------------------------------------------------------- // Again, boosts multiplied together, unless they are along the // same direction, will not return a pure boost, but instead, a boost // and a rotation. LorentzTransformation lt1 = bx1 * by1; // <------------- cout << "lt1 = " << lt1 << endl; LorentzBoost b1; Rotation r1; lt1.decompose( b1, r1 ); cout << "b1 = " << b1 << endl << "r1 = " << r1 << endl; // Here is how to find the inverse of an Axis Boost: //-------------------------------------------------- LorentzBoostZ bz2 = inverseOf ( bz1 ); // <------------- cout << "bz1 = " << bz1 << endl; cout << "bz2 = " << bz2 << endl; // Here is how to invert an Axis Boost in place: //---------------------------------------------- bz2.invert(); // <------------- cout << "Now, bz1 = " << bz1 << endl; // ***** Comparisons // Here is how to apply exact comparisons to Axis Boosts: //------------------------------------------------------- bx1 = bx3; if ( bx1 == bx3 ) { // <------------- cout << bx1 << " ==\n " << bx3 << endl; } if ( bx1 != bx2 ) { // <------------- cout << bx1 << " !=\n " << bx2 << endl; } // Other comparisons > < >= <= are also provided so that // sort templates can be used on lists of Axis Boosts. // Here is how to determine if two Axis Boosts are "nearly equal": //---------------------------------------------------------------- bx1.set( .4500001); bx2.set( .4500002); if ( bx1 != bx2 ) { cout << bx1 << " !=\n " << bx2 << endl; } if ( bx1.isNear(bx2) ) { // <------------- cout << "But, " << bx1 << " isNear\n " << bx2 << endl; } // Here is how to determine if an Axis Boost // is near a generic LorentzBoost: //------------------------------------------ LorentzBoost b2 ( UnitVector( 0.0000001, 0.0000001, 0.9999999 ), .85 ); LorentzBoostZ bz3 ( .85 ); if ( b2.isNear( bz3 ) ) { // <------------- cout << b2 << " isNear\n " << bz3 << endl; } // Working with certain tolerances follows the same format as // described earlier in tutorial example lt-3 with LorentzBoosts // and LorentzTransformations and for that reason is not detailed // here. return 0; } /* end of main */