Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
JGEOMETRY3D::JRotation3D Class Reference

Rotation matrix. More...

#include <JRotation3D.hh>

Inheritance diagram for JGEOMETRY3D::JRotation3D:
JMATH::JMatrix3D JMATH::JMath< JFirst_t, JSecond_t > JMATH::JMath< JMatrix3D > JLANG::JEquals< JFirst_t, JSecond_t > JDETECTOR::JCompassMatrix JGEOMETRY3D::JEulerMatrix3D JGEOMETRY3D::JTransformation3D

Public Types

enum  JDerivative_t { THETA, PHI }
 

Public Member Functions

 JRotation3D ()
 Default constructor (= identity matrix). More...
 
 JRotation3D (const JAngle3D &dir)
 Constructor. More...
 
 JRotation3D (const JAngle3D &dir, const JDerivative_t &dev)
 Constructor. More...
 
 JRotation3D (const JRotation3X &R)
 Constructor. More...
 
 JRotation3D (const JRotation3Y &R)
 Constructor. More...
 
 JRotation3D (const JRotation3Z &R)
 Constructor. More...
 
const JRotation3DgetRotation () const
 Get rotation. More...
 
JRotation3Dtranspose ()
 Transpose. More...
 
JRotation3Dmul (const JRotation3D &A, const JRotation3D &B)
 Matrix multiplication. More...
 
void rotate (double &__x, double &__y, double &__z) const
 Rotate. More...
 
void rotate_back (double &__x, double &__y, double &__z) const
 Rotate back. More...
 
JMatrix3DsetIdentity ()
 Set to identity matrix. More...
 
void set (const JMatrix3D &A)
 Set matrix. More...
 
JMatrix3Dreset ()
 Set matrix to the null matrix. More...
 
JMatrix3Dnegate ()
 Negate matrix. More...
 
JMatrix3Dadd (const JMatrix3D &A)
 Matrix addition. More...
 
JMatrix3Dsub (const JMatrix3D &A)
 Matrix subtraction. More...
 
JMatrix3Dmul (const double factor)
 Scale matrix. More...
 
JMatrix3Dmul (const JMatrix3D &A, const JMatrix3D &B)
 Matrix multiplication. More...
 
JMatrix3Dmul (const JNullType &object)
 Multiply with object. More...
 
JMatrix3Ddiv (const double factor)
 Scale matrix. More...
 
bool equals (const JMatrix3D &A, const double eps=std::numeric_limits< double >::min()) const
 Equality. More...
 
bool isIdentity (const double eps=std::numeric_limits< double >::min()) const
 Test identity. More...
 
double getDeterminant () const
 Get determinant of matrix. More...
 
void transform (double &__x, double &__y, double &__z) const
 Transform. More...
 
JFirst_t & mul (const JSecond_t &object)
 Multiply with object. More...
 

Static Public Member Functions

static const JMatrix3DgetInstance ()
 Get reference to unique instance of this class object. More...
 
static const JMatrix3DgetIdentity ()
 Get reference to unique instance of this class object. More...
 

Public Attributes

double a00
 
double a01
 
double a02
 
double a10
 
double a11
 
double a12
 
double a20
 
double a21
 
double a22
 

Detailed Description

Rotation matrix.

Definition at line 108 of file JRotation3D.hh.

Member Enumeration Documentation

Enumerator
THETA 
PHI 

Definition at line 116 of file JRotation3D.hh.

Constructor & Destructor Documentation

JGEOMETRY3D::JRotation3D::JRotation3D ( )
inline

Default constructor (= identity matrix).

Definition at line 122 of file JRotation3D.hh.

122  :
123  JMatrix3D()
124  {
125  setIdentity();
126  }
JMatrix3D()
Default constructor.
JMatrix3D & setIdentity()
Set to identity matrix.
JGEOMETRY3D::JRotation3D::JRotation3D ( const JAngle3D dir)
inline

Constructor.

The matrix is defined such that the rotation of a vector in the given direction ends up along the z-axis and the back rotation of a vector parallel to the z-axis ends up in the given direction.

Parameters
dirdirection

Definition at line 137 of file JRotation3D.hh.

137  :
138  JMatrix3D()
139  {
140  const double ct = cos(dir.getTheta());
141  const double st = sin(dir.getTheta());
142  const double cp = cos(dir.getPhi());
143  const double sp = sin(dir.getPhi());
144 
145  a00 = ct*cp; a01 = ct*sp; a02 = -st;
146  a10 = -sp; a11 = cp; a12 = 0.0;
147  a20 = st*cp; a21 = st*sp; a22 = +ct;
148  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:94
JMatrix3D()
Default constructor.
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:83
JGEOMETRY3D::JRotation3D::JRotation3D ( const JAngle3D dir,
const JDerivative_t dev 
)
inline

Constructor.

The matrix is defined such that the rotation of a vector in the given direction ends up along the z-axis and the back rotation of a vector parallel to the z-axis ends up in the given direction.

Parameters
dirdirection
devderivative

Definition at line 160 of file JRotation3D.hh.

161  :
162  JMatrix3D()
163  {
164  const double ct = cos(dir.getTheta());
165  const double st = sin(dir.getTheta());
166  const double cp = cos(dir.getPhi());
167  const double sp = sin(dir.getPhi());
168 
169  switch (dev) {
170 
171  case THETA:
172 
173  a00 = -st*cp; a01 = -st*sp; a02 = -ct;
174  a10 = 0.0; a11 = 0.0; a12 = 0.0;
175  a20 = ct*cp; a21 = ct*sp; a22 = -st;
176 
177  break;
178 
179  case PHI:
180 
181  a00 = -ct*sp; a01 = ct*cp; a02 = 0.0;
182  a10 = -cp; a11 = -sp; a12 = 0.0;
183  a20 = -st*sp; a21 = st*cp; a22 = 0.0;
184 
185  break;
186  }
187  }
double getPhi() const
Get phi angle.
Definition: JAngle3D.hh:94
JMatrix3D()
Default constructor.
double getTheta() const
Get theta angle.
Definition: JAngle3D.hh:83
JGEOMETRY3D::JRotation3D::JRotation3D ( const JRotation3X R)
inline

Constructor.

Parameters
R2D rotation matrix around X-axis

Definition at line 195 of file JRotation3D.hh.

195  :
196  JMatrix3D()
197  {
198  a00 = 1.0; a01 = 0.0; a02 = 0.0;
199  a10 = 0.0; a11 = R.a00; a12 = R.a01;
200  a20 = 0.0; a21 = R.a10; a22 = R.a11;
201  }
JMatrix3D()
Default constructor.
JGEOMETRY3D::JRotation3D::JRotation3D ( const JRotation3Y R)
inline

Constructor.

Parameters
R2D rotation matrix around Y-axis

Definition at line 209 of file JRotation3D.hh.

209  :
210  JMatrix3D()
211  {
212  a00 = R.a00; a01 = 0.0; a02 = R.a01;
213  a10 = 0.0; a11 = 1.0; a12 = 0.0;
214  a20 = R.a10; a21 = 0.0; a22 = R.a11;
215  }
JMatrix3D()
Default constructor.
JGEOMETRY3D::JRotation3D::JRotation3D ( const JRotation3Z R)
inline

Constructor.

Parameters
R2D rotation matrix around Z-axis

Definition at line 223 of file JRotation3D.hh.

223  :
224  JMatrix3D()
225  {
226  a00 = R.a00; a01 = R.a01; a02 = 0.0;
227  a10 = R.a10; a11 = R.a11; a12 = 0.0;
228  a20 = 0.0; a21 = 0.0; a22 = 1.0;
229  }
JMatrix3D()
Default constructor.

Member Function Documentation

const JRotation3D& JGEOMETRY3D::JRotation3D::getRotation ( ) const
inline

Get rotation.

Returns
rotation

Definition at line 237 of file JRotation3D.hh.

238  {
239  return static_cast<const JRotation3D&>(*this);
240  }
Rotation matrix.
Definition: JRotation3D.hh:108
JRotation3D& JGEOMETRY3D::JRotation3D::transpose ( )
inline

Transpose.

Definition at line 246 of file JRotation3D.hh.

247  {
248  static_cast<JMatrix3D&>(*this).transpose();
249 
250  return *this;
251  }
JMatrix3D()
Default constructor.
JRotation3D& JGEOMETRY3D::JRotation3D::mul ( const JRotation3D A,
const JRotation3D B 
)
inline

Matrix multiplication.

Parameters
Amatrix
Bmatrix
Returns
this matrix

Definition at line 261 of file JRotation3D.hh.

263  {
264  static_cast<JMatrix3D&>(*this).mul(A, B);
265 
266  return *this;
267  }
JMatrix3D()
Default constructor.
void JGEOMETRY3D::JRotation3D::rotate ( double &  __x,
double &  __y,
double &  __z 
) const
inline

Rotate.

Parameters
__xx value
__yy value
__zz value

Definition at line 277 of file JRotation3D.hh.

278  {
279  const double x = a00 * __x + a01 * __y + a02 * __z;
280  const double y = a10 * __x + a11 * __y + a12 * __z;
281  const double z = a20 * __x + a21 * __y + a22 * __z;
282 
283  __x = x;
284  __y = y;
285  __z = z;
286  }
void JGEOMETRY3D::JRotation3D::rotate_back ( double &  __x,
double &  __y,
double &  __z 
) const
inline

Rotate back.

Parameters
__xx value
__yy value
__zz value

Definition at line 296 of file JRotation3D.hh.

297  {
298  const double x = a00 * __x + a10 * __y + a20 * __z;
299  const double y = a01 * __x + a11 * __y + a21 * __z;
300  const double z = a02 * __x + a12 * __y + a22 * __z;
301 
302  __x = x;
303  __y = y;
304  __z = z;
305  }
static const JMatrix3D& JMATH::JMatrix3D::getInstance ( )
inlinestaticinherited

Get reference to unique instance of this class object.

Returns
zero matrix

Definition at line 78 of file JMath/JMatrix3D.hh.

79  {
80  static JMatrix3D matrix;
81 
82  return matrix;
83  }
3 x 3 matrix
JMatrix3D& JMATH::JMatrix3D::setIdentity ( )
inlineinherited

Set to identity matrix.

Returns
this matrix

Definition at line 91 of file JMath/JMatrix3D.hh.

92  {
93  a00 = 1.0; a01 = 0.0; a02 = 0.0;
94  a10 = 0.0; a11 = 1.0; a12 = 0.0;
95  a20 = 0.0; a21 = 0.0; a22 = 1.0;
96 
97  return *this;
98  }
static const JMatrix3D& JMATH::JMatrix3D::getIdentity ( )
inlinestaticinherited

Get reference to unique instance of this class object.

Returns
identity matrix

Definition at line 106 of file JMath/JMatrix3D.hh.

107  {
108  static JMatrix3D matrix(JMatrix3D().setIdentity());
109 
110  return matrix;
111  }
JMatrix3D()
Default constructor.
3 x 3 matrix
JMatrix3D & setIdentity()
Set to identity matrix.
void JMATH::JMatrix3D::set ( const JMatrix3D A)
inlineinherited

Set matrix.

Parameters
Amatrix

Definition at line 119 of file JMath/JMatrix3D.hh.

120  {
121  static_cast<JMatrix3D&>(*this) = A;
122  }
3 x 3 matrix
JMatrix3D& JMATH::JMatrix3D::reset ( )
inlineinherited

Set matrix to the null matrix.

Returns
this matrix

Definition at line 130 of file JMath/JMatrix3D.hh.

131  {
132  *this = JMatrix3D();
133 
134  return *this;
135  }
JMatrix3D()
Default constructor.
JMatrix3D& JMATH::JMatrix3D::negate ( )
inlineinherited

Negate matrix.

Returns
-this matrix

Definition at line 160 of file JMath/JMatrix3D.hh.

161  {
162  a00 = -a00; a01 = -a01; a02 = -a02;
163  a10 = -a10; a11 = -a11; a12 = -a12;
164  a20 = -a20; a21 = -a21; a22 = -a22;
165 
166  return *this;
167  }
JMatrix3D& JMATH::JMatrix3D::add ( const JMatrix3D A)
inlineinherited

Matrix addition.

Parameters
Amatrix
Returns
this matrix + A

Definition at line 176 of file JMath/JMatrix3D.hh.

177  {
178  a00 += A.a00; a01 += A.a01; a02 += A.a02;
179  a10 += A.a10; a11 += A.a11; a12 += A.a12;
180  a20 += A.a20; a21 += A.a21; a22 += A.a22;
181 
182  return *this;
183  }
JMatrix3D& JMATH::JMatrix3D::sub ( const JMatrix3D A)
inlineinherited

Matrix subtraction.

Parameters
Amatrix
Returns
this matrix - A

Definition at line 192 of file JMath/JMatrix3D.hh.

193  {
194  a00 -= A.a00; a01 -= A.a01; a02 -= A.a02;
195  a10 -= A.a10; a11 -= A.a11; a12 -= A.a12;
196  a20 -= A.a20; a21 -= A.a21; a22 -= A.a22;
197 
198  return *this;
199  }
JMatrix3D& JMATH::JMatrix3D::mul ( const double  factor)
inlineinherited

Scale matrix.

Parameters
factorfactor
Returns
this matrix * factor

Definition at line 208 of file JMath/JMatrix3D.hh.

209  {
210  a00 *= factor; a01 *= factor; a02 *= factor;
211  a10 *= factor; a11 *= factor; a12 *= factor;
212  a20 *= factor; a21 *= factor; a22 *= factor;
213 
214  return *this;
215  }
JMatrix3D& JMATH::JMatrix3D::mul ( const JMatrix3D A,
const JMatrix3D B 
)
inlineinherited

Matrix multiplication.

Parameters
Amatrix
Bmatrix
Returns
this matrix

Definition at line 241 of file JMath/JMatrix3D.hh.

243  {
244  a00 = A.a00 * B.a00 + A.a01 * B.a10 + A.a02 * B.a20;
245  a01 = A.a00 * B.a01 + A.a01 * B.a11 + A.a02 * B.a21;
246  a02 = A.a00 * B.a02 + A.a01 * B.a12 + A.a02 * B.a22;
247 
248  a10 = A.a10 * B.a00 + A.a11 * B.a10 + A.a12 * B.a20;
249  a11 = A.a10 * B.a01 + A.a11 * B.a11 + A.a12 * B.a21;
250  a12 = A.a10 * B.a02 + A.a11 * B.a12 + A.a12 * B.a22;
251 
252  a20 = A.a20 * B.a00 + A.a21 * B.a10 + A.a22 * B.a20;
253  a21 = A.a20 * B.a01 + A.a21 * B.a11 + A.a22 * B.a21;
254  a22 = A.a20 * B.a02 + A.a21 * B.a12 + A.a22 * B.a22;
255 
256  return *this;
257  }
JMatrix3D & JMATH::JMath< JMatrix3D , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }
Auxiliary class for product evaluation of objects.
Definition: JCalculator.hh:18
JMatrix3D& JMATH::JMatrix3D::div ( const double  factor)
inlineinherited

Scale matrix.

Parameters
factorfactor
Returns
this matrix / factor

Definition at line 224 of file JMath/JMatrix3D.hh.

225  {
226  a00 /= factor; a01 /= factor; a02 /= factor;
227  a10 /= factor; a11 /= factor; a12 /= factor;
228  a20 /= factor; a21 /= factor; a22 /= factor;
229 
230  return *this;
231  }
bool JMATH::JMatrix3D::equals ( const JMatrix3D A,
const double  eps = std::numeric_limits<double>::min() 
) const
inlineinherited

Equality.

Parameters
Amatrix
epsnumerical precision
Returns
true if matrices identical; else false

Definition at line 267 of file JMath/JMatrix3D.hh.

269  {
270  return (fabs(a00 - A.a00) <= eps &&
271  fabs(a01 - A.a01) <= eps &&
272  fabs(a02 - A.a02) <= eps &&
273  fabs(a10 - A.a10) <= eps &&
274  fabs(a11 - A.a11) <= eps &&
275  fabs(a12 - A.a12) <= eps &&
276  fabs(a20 - A.a20) <= eps &&
277  fabs(a21 - A.a21) <= eps &&
278  fabs(a22 - A.a22) <= eps);
279  }
bool JMATH::JMatrix3D::isIdentity ( const double  eps = std::numeric_limits<double>::min()) const
inlineinherited

Test identity.

Parameters
epsnumerical precision
Returns
true if identity matrix; else false

Definition at line 288 of file JMath/JMatrix3D.hh.

289  {
290  return equals(getIdentity(), eps);
291  }
static const JMatrix3D & getIdentity()
Get reference to unique instance of this class object.
bool equals(const JMatrix3D &A, const double eps=std::numeric_limits< double >::min()) const
Equality.
double JMATH::JMatrix3D::getDeterminant ( ) const
inlineinherited

Get determinant of matrix.

Returns
determinant of matrix

Definition at line 299 of file JMath/JMatrix3D.hh.

300  {
301  double det = 0.0;
302 
303  det += a00 * (a11 * a22 - a21 * a12);
304  det -= a01 * (a10 * a22 - a20 * a12);
305  det += a02 * (a10 * a21 - a20 * a11);
306 
307  return det;
308  }
void JMATH::JMatrix3D::transform ( double &  __x,
double &  __y,
double &  __z 
) const
inlineinherited

Transform.

Parameters
__xx value
__yy value
__zz value

Definition at line 318 of file JMath/JMatrix3D.hh.

319  {
320  const double x = a00 * __x + a01 * __y + a02 * __z;
321  const double y = a10 * __x + a11 * __y + a12 * __z;
322  const double z = a20 * __x + a21 * __y + a22 * __z;
323 
324  __x = x;
325  __y = y;
326  __z = z;
327  }
template<class JFirst_t, class JSecond_t = JNullType>
JFirst_t& JMATH::JMath< JFirst_t, JSecond_t >::mul ( const JSecond_t &  object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }
Auxiliary class for product evaluation of objects.
Definition: JCalculator.hh:18

Member Data Documentation

double JMATH::JMatrix3D::a00
inherited

Definition at line 385 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a01
inherited

Definition at line 385 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a02
inherited

Definition at line 385 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a10
inherited

Definition at line 386 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a11
inherited

Definition at line 386 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a12
inherited

Definition at line 386 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a20
inherited

Definition at line 387 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a21
inherited

Definition at line 387 of file JMath/JMatrix3D.hh.

double JMATH::JMatrix3D::a22
inherited

Definition at line 387 of file JMath/JMatrix3D.hh.


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