[4] | 1 | // -*- C++ -*-
|
---|
| 2 | // ---------------------------------------------------------------------------
|
---|
| 3 | //
|
---|
| 4 | // This file is a part of the CLHEP - a Class Library for High Energy Physics.
|
---|
| 5 | //
|
---|
| 6 | // This is the definitions of the inline member functions of the
|
---|
| 7 | // HepRotationZ class
|
---|
| 8 | //
|
---|
| 9 |
|
---|
| 10 | #include <cmath>
|
---|
| 11 | #include "CLHEP/Units/PhysicalConstants.h"
|
---|
| 12 |
|
---|
| 13 | namespace CLHEP {
|
---|
| 14 |
|
---|
| 15 | inline double HepRotationZ::xx() const { return c; }
|
---|
| 16 | inline double HepRotationZ::xy() const { return -s; }
|
---|
| 17 | inline double HepRotationZ::yx() const { return s; }
|
---|
| 18 | inline double HepRotationZ::yy() const { return c; }
|
---|
| 19 |
|
---|
| 20 | inline double HepRotationZ::zz() const { return 1.0; }
|
---|
| 21 | inline double HepRotationZ::zy() const { return 0.0; }
|
---|
| 22 | inline double HepRotationZ::zx() const { return 0.0; }
|
---|
| 23 | inline double HepRotationZ::yz() const { return 0.0; }
|
---|
| 24 | inline double HepRotationZ::xz() const { return 0.0; }
|
---|
| 25 |
|
---|
| 26 | inline HepRep3x3 HepRotationZ::rep3x3() const {
|
---|
| 27 | return HepRep3x3 ( c, -s, 0.0,
|
---|
| 28 | s, c, 0.0,
|
---|
| 29 | 0.0, 0.0, 1.0 );
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | inline HepRotationZ::HepRotationZ() : d(0.0), s(0.0), c(1.0) {}
|
---|
| 33 |
|
---|
| 34 | inline HepRotationZ::HepRotationZ(const HepRotationZ & orig) :
|
---|
| 35 | d(orig.d), s(orig.s), c(orig.c)
|
---|
| 36 | {}
|
---|
| 37 |
|
---|
| 38 | inline HepRotationZ::HepRotationZ(double dd, double ss, double cc) :
|
---|
| 39 | d(dd), s(ss), c(cc)
|
---|
| 40 | {}
|
---|
| 41 |
|
---|
| 42 | inline HepRotationZ & HepRotationZ::operator= (const HepRotationZ & orig) {
|
---|
| 43 | d = orig.d;
|
---|
| 44 | s = orig.s;
|
---|
| 45 | c = orig.c;
|
---|
| 46 | return *this;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | inline HepRotationZ::~HepRotationZ() {}
|
---|
| 50 |
|
---|
| 51 | inline Hep3Vector HepRotationZ::colX() const
|
---|
| 52 | { return Hep3Vector ( c, s, 0.0 ); }
|
---|
| 53 | inline Hep3Vector HepRotationZ::colY() const
|
---|
| 54 | { return Hep3Vector ( -s, c, 0.0 ); }
|
---|
| 55 | inline Hep3Vector HepRotationZ::colZ() const
|
---|
| 56 | { return Hep3Vector ( 0.0, 0.0, 1.0 ); }
|
---|
| 57 |
|
---|
| 58 | inline Hep3Vector HepRotationZ::rowX() const
|
---|
| 59 | { return Hep3Vector ( c, -s, 0.0 ); }
|
---|
| 60 | inline Hep3Vector HepRotationZ::rowY() const
|
---|
| 61 | { return Hep3Vector ( s, c, 0.0 ); }
|
---|
| 62 | inline Hep3Vector HepRotationZ::rowZ() const
|
---|
| 63 | { return Hep3Vector ( 0.0, 0.0, 1.0 ); }
|
---|
| 64 |
|
---|
| 65 | inline double HepRotationZ::getPhi () const { return phi(); }
|
---|
| 66 | inline double HepRotationZ::getTheta() const { return theta(); }
|
---|
| 67 | inline double HepRotationZ::getPsi () const { return psi(); }
|
---|
| 68 | inline double HepRotationZ::getDelta() const { return d; }
|
---|
| 69 | inline Hep3Vector HepRotationZ::getAxis () const { return axis(); }
|
---|
| 70 |
|
---|
| 71 | inline double HepRotationZ::delta() const { return d; }
|
---|
| 72 | inline Hep3Vector HepRotationZ::axis() const { return Hep3Vector(0,0,1); }
|
---|
| 73 |
|
---|
| 74 | inline HepAxisAngle HepRotationZ::axisAngle() const {
|
---|
| 75 | return HepAxisAngle ( axis(), delta() );
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | inline void HepRotationZ::getAngleAxis
|
---|
| 79 | (double & delta, Hep3Vector & axis) const {
|
---|
| 80 | delta = d;
|
---|
| 81 | axis = getAxis();
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | inline bool HepRotationZ::isIdentity() const {
|
---|
| 85 | return ( d==0 );
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | inline int HepRotationZ::compare ( const HepRotationZ & r ) const {
|
---|
| 89 | if (d > r.d) return 1; else if (d < r.d) return -1; else return 0;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | inline bool HepRotationZ::operator==(const HepRotationZ & r) const
|
---|
| 93 | { return (d==r.d); }
|
---|
| 94 | inline bool HepRotationZ::operator!=(const HepRotationZ & r) const
|
---|
| 95 | { return (d!=r.d); }
|
---|
| 96 | inline bool HepRotationZ::operator>=(const HepRotationZ & r) const
|
---|
| 97 | { return (d>=r.d); }
|
---|
| 98 | inline bool HepRotationZ::operator<=(const HepRotationZ & r) const
|
---|
| 99 | { return (d<=r.d); }
|
---|
| 100 | inline bool HepRotationZ::operator> (const HepRotationZ & r) const
|
---|
| 101 | { return (d> r.d); }
|
---|
| 102 | inline bool HepRotationZ::operator< (const HepRotationZ & r) const
|
---|
| 103 | { return (d< r.d); }
|
---|
| 104 |
|
---|
| 105 | inline void HepRotationZ::rectify() {
|
---|
| 106 | d = proper(d); // Just in case!
|
---|
| 107 | s = std::sin(d);
|
---|
| 108 | c = std::cos(d);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | inline Hep3Vector HepRotationZ::operator() (const Hep3Vector & p) const {
|
---|
| 112 | double x = p.x();
|
---|
| 113 | double y = p.y();
|
---|
| 114 | double z = p.z();
|
---|
| 115 | return Hep3Vector( x * c - y * s,
|
---|
| 116 | x * s + y * c,
|
---|
| 117 | z );
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | inline Hep3Vector HepRotationZ::operator * (const Hep3Vector & p) const {
|
---|
| 121 | return operator()(p);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | inline HepLorentzVector HepRotationZ::operator()
|
---|
| 125 | ( const HepLorentzVector & w ) const {
|
---|
| 126 | return HepLorentzVector( operator() (w.vect()) , w.t() );
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | inline HepLorentzVector HepRotationZ::operator *
|
---|
| 130 | (const HepLorentzVector & p) const {
|
---|
| 131 | return operator()(p);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | inline HepRotationZ & HepRotationZ::operator *= (const HepRotationZ & m) {
|
---|
| 135 | return *this = (*this) * (m);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | inline HepRotationZ & HepRotationZ::transform(const HepRotationZ & m) {
|
---|
| 139 | return *this = m * (*this);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | inline double HepRotationZ::proper( double delta ) {
|
---|
| 143 | // -PI < d <= PI
|
---|
| 144 | if ( std::fabs(delta) < CLHEP::pi ) {
|
---|
| 145 | return delta;
|
---|
| 146 | } else {
|
---|
| 147 | register double x = delta / (CLHEP::twopi);
|
---|
| 148 | return (CLHEP::twopi) * ( x + std::floor(.5-x) );
|
---|
| 149 | }
|
---|
| 150 | } // proper()
|
---|
| 151 |
|
---|
| 152 | inline HepRotationZ HepRotationZ::operator * ( const HepRotationZ & rz ) const {
|
---|
| 153 | return HepRotationZ ( HepRotationZ::proper(d+rz.d),
|
---|
| 154 | s*rz.c + c*rz.s,
|
---|
| 155 | c*rz.c - s*rz.s );
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | inline HepRotationZ HepRotationZ::inverse() const {
|
---|
| 159 | return HepRotationZ( proper(-d), -s, c );
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | inline HepRotationZ inverseOf(const HepRotationZ & r) {
|
---|
| 163 | return r.inverse();
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | inline HepRotationZ & HepRotationZ::invert() {
|
---|
| 167 | return *this=inverse();
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | inline HepLorentzVector HepRotationZ::col1() const
|
---|
| 171 | { return HepLorentzVector (colX(), 0); }
|
---|
| 172 | inline HepLorentzVector HepRotationZ::col2() const
|
---|
| 173 | { return HepLorentzVector (colY(), 0); }
|
---|
| 174 | inline HepLorentzVector HepRotationZ::col3() const
|
---|
| 175 | { return HepLorentzVector (colZ(), 0); }
|
---|
| 176 | inline HepLorentzVector HepRotationZ::col4() const
|
---|
| 177 | { return HepLorentzVector (0,0,0,1); }
|
---|
| 178 | inline HepLorentzVector HepRotationZ::row1() const
|
---|
| 179 | { return HepLorentzVector (rowX(), 0); }
|
---|
| 180 | inline HepLorentzVector HepRotationZ::row2() const
|
---|
| 181 | { return HepLorentzVector (rowY(), 0); }
|
---|
| 182 | inline HepLorentzVector HepRotationZ::row3() const
|
---|
| 183 | { return HepLorentzVector (rowZ(), 0); }
|
---|
| 184 | inline HepLorentzVector HepRotationZ::row4() const
|
---|
| 185 | { return HepLorentzVector (0,0,0,1); }
|
---|
| 186 | inline double HepRotationZ::xt() const { return 0.0; }
|
---|
| 187 | inline double HepRotationZ::yt() const { return 0.0; }
|
---|
| 188 | inline double HepRotationZ::zt() const { return 0.0; }
|
---|
| 189 | inline double HepRotationZ::tx() const { return 0.0; }
|
---|
| 190 | inline double HepRotationZ::ty() const { return 0.0; }
|
---|
| 191 | inline double HepRotationZ::tz() const { return 0.0; }
|
---|
| 192 | inline double HepRotationZ::tt() const { return 1.0; }
|
---|
| 193 |
|
---|
| 194 | inline HepRep4x4 HepRotationZ::rep4x4() const {
|
---|
| 195 | return HepRep4x4 ( c, -s, 0.0, 0.0,
|
---|
| 196 | s, c, 0.0, 0.0,
|
---|
| 197 | 0.0, 0.0, 1.0, 0.0,
|
---|
| 198 | 0.0, 0.0, 0.0, 1.0 );
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | inline double HepRotationZ::getTolerance() {
|
---|
| 202 | return Hep4RotationInterface::tolerance;
|
---|
| 203 | }
|
---|
| 204 | inline double HepRotationZ::setTolerance(double tol) {
|
---|
| 205 | return Hep4RotationInterface::setTolerance(tol);
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | } // namespace CLHEP
|
---|