38 #ifndef EGS_TRANSFORMATIONS_
40 #define EGS_TRANSFORMATIONS_
69 EGS_Float
rxx, rxy, rxz,
94 EGS_Float yx, EGS_Float yy, EGS_Float yz,
95 EGS_Float zx, EGS_Float zy, EGS_Float zz) {
128 EGS_Float d = det() - 1;
149 EGS_Float sinz = v.
x*v.
x + v.
y*v.
y;
150 EGS_Float norm = sinz + v.
z*v.
z;
151 if (norm <
epsilon)
egsFatal(
"EGS_RotationMatrix::EGS_RotationMatrix: \n"
152 " no construction from a zero vector possible!\n");
156 EGS_Float cphi = v.
x/sinz;
157 register EGS_Float sphi = v.
y/sinz;
158 EGS_Float cost = v.
z/norm;
159 register EGS_Float sint = -sinz/norm;
160 *
this = rotY(cost,sint)*rotZ(cphi,sphi);
185 *
this = rotX(alpha)*rotY(beta)*rotZ(gamma);
193 *
this = rotZ(phi)*rotX(theta);
213 ((rxx == m.
rxx) && (rxy == m.rxy) && (rxz == m.rxz) &&
214 (ryx == m.ryx) && (ryy == m.ryy) && (ryz == m.ryz) &&
215 (rzx == m.rxz) && (rzy == m.rzy) && (rzz == m.rzz)) ?
true :
false;
240 ryx*v.
x + ryy*v.
y + ryz*v.
z,
241 rzx*v.
x + rzy*v.
y + rzz*v.
z);
248 rxx*m.
rxx+rxy*m.ryx+rxz*m.rzx, rxx*m.rxy+rxy*m.ryy+rxz*m.rzy,
249 rxx*m.rxz+rxy*m.ryz+rxz*m.rzz,
250 ryx*m.
rxx+ryy*m.ryx+ryz*m.rzx, ryx*m.rxy+ryy*m.ryy+ryz*m.rzy,
251 ryx*m.rxz+ryy*m.ryz+ryz*m.rzz,
252 rzx*m.
rxx+rzy*m.ryx+rzz*m.rzx, rzx*m.rxy+rzy*m.ryy+rzz*m.rzy,
253 rzx*m.rxz+rzy*m.ryz+rzz*m.rzz);
261 return *
this = operator * (m);
273 *
this = m.operator * (*this);
292 return *
this = inverse();
300 (EGS_Float)1,(EGS_Float)0,(EGS_Float)0,
301 (EGS_Float)0, cphi, sphi,
302 (EGS_Float)0, -sphi, cphi);
310 (EGS_Float)0, (EGS_Float)1, (EGS_Float)0,
311 sphi, (EGS_Float)0, cphi);
319 -sphi, cphi, (EGS_Float)0,
320 (EGS_Float)0,(EGS_Float)0, (EGS_Float)1);
325 return rotX(cos(phi),sin(phi));
330 return rotY(cos(phi),sin(phi));
335 return rotZ(cos(phi),sin(phi));
342 return rotV(cos(phi),sin(phi),v);
349 return (m.
inverse())*(rotZ(cphi,sphi))*(m);
354 return rxx*ryy*rzz + rxy*ryz*rzx + ryx*rzy*rxz -
355 rxz*ryy*rzx - rxy*ryx*rzz - rzy*ryz*rxx;
364 v.
x*m.rxy+v.
y*m.ryy+v.
z*m.rzy,
365 v.
x*m.rxz+v.
y*m.ryz+v.
z*m.rzz);
377 inline EGS_Float xx()
const {
380 inline EGS_Float xy()
const {
383 inline EGS_Float xz()
const {
386 inline EGS_Float yx()
const {
389 inline EGS_Float yy()
const {
392 inline EGS_Float yz()
const {
395 inline EGS_Float zx()
const {
398 inline EGS_Float zy()
const {
401 inline EGS_Float zz()
const {
432 R(tr.R),t(tr.t),has_t(tr.has_t),has_R(tr.has_R) {};
438 if (t.length2() > 0) {
468 if (t.length2() > 0) {
502 return *
this = operator * (tr);
511 return *
this = operator * (m);
534 return ((v-tr.t)*tr.R);
604 return (!has_R && !has_t);
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_RotationMatrix & operator*=(const EGS_RotationMatrix &m)
Multiplies the invoking object with m from the right and assigns the resulting matrix to the invoking...
friend EGS_Vector & operator*=(EGS_Vector &v, const EGS_RotationMatrix &m)
Multiplies the invoking vector v from the right with the matrix m and assigns the result to the invok...
EGS_RotationMatrix operator*(const EGS_RotationMatrix &m) const
Multiplies the invoking object with m from the right and returns the result.
static EGS_RotationMatrix rotY(EGS_Float phi)
Returns a rotation around the y-axis by the angle phi.
static EGS_RotationMatrix rotV(EGS_Float cphi, EGS_Float sphi, const EGS_Vector &v)
static EGS_RotationMatrix rotX(EGS_Float phi)
Returns a rotation around the x-axis by the angle phi.
EGS_RotationMatrix(EGS_Float phi, EGS_Float theta)
Constructs a rotation matrix from the angles theta and phi (polar and azimuthal) as ...
EGS_RotationMatrix()
Default constructor, results in a unit matrix object.
A class for vector rotations.
EGS_Vector methods for the manipulation of 3D vectors in cartesian co-ordinates.
EGS_RotationMatrix & operator=(const EGS_RotationMatrix &m)
Assignment operator.
A class representing 3D vectors.
Global egspp functions header file.
EGS_Vector operator*(const EGS_Vector &v) const
Returns the rotated a vector .
static EGS_RotationMatrix rotY(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the y-axis by the angle with cphi, sphi = .
bool operator==(const EGS_RotationMatrix &m)
Comparison operator.
EGS_RotationMatrix(EGS_Float alpha, EGS_Float beta, EGS_Float gamma)
Constructs a rotation matrix from rotation angles around the x-, y-, and z-axis as ...
EGS_RotationMatrix T()
Returns the transposed matrix.
EGS_RotationMatrix & invert()
Inverts the matrix and returns a reference to it.
bool isI() const
Returns true, if this object is approximately the unit matrix, false otherwise.
EGS_InfoFunction EGS_EXPORT egsFatal
Always use this function for reporting fatal errors.
static EGS_RotationMatrix rotZ(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the z-axis by the angle with cphi, sphi = .
EGS_RotationMatrix inverse() const
Returns the inverse matrix.
bool isRotation() const
Is this object a real rotation matrix?
EGS_RotationMatrix(const EGS_RotationMatrix &m)
Copy constructor.
static EGS_RotationMatrix rotV(EGS_Float phi, const EGS_Vector &v)
Returns a rotation by the angle phi around the axis defined by the vector v.
Attempts to fix broken math header files.
EGS_Float det() const
Calculates and returns the determinant of the matrix.
void multiply(const EGS_RotationMatrix &m)
Multiplies the invoking object with m from the left and returns the result.
EGS_RotationMatrix(EGS_Float xx, EGS_Float xy, EGS_Float xz, EGS_Float yx, EGS_Float yy, EGS_Float yz, EGS_Float zx, EGS_Float zy, EGS_Float zz)
Construct a rotation matrix object from 9 floating point numbers.
const EGS_Float epsilon
The epsilon constant for floating point comparisons.
Defines the EGS_EXPORT and EGS_LOCAL macros.
EGS_RotationMatrix(const EGS_Vector &v)
Create a rotation matrix from the vector v.
friend EGS_Vector operator*(const EGS_Vector &v, const EGS_RotationMatrix &m)
Multiplies the invoking vector v from the right with the matrix m and returns the result...
static EGS_RotationMatrix rotZ(EGS_Float phi)
Returns a rotation around the z-axis by the angle phi.
static EGS_RotationMatrix rotX(EGS_Float cphi, EGS_Float sphi)
Returns a rotation around the x-axis by the angle with cphi, sphi = .