Matrix3.hh
Go to the documentation of this file.
00001 #ifndef RIVET_MATH_MATRIX3 00002 #define RIVET_MATH_MATRIX3 00003 00004 #include "Rivet/Math/MathHeader.hh" 00005 #include "Rivet/Math/MathUtils.hh" 00006 #include "Rivet/Math/MatrixN.hh" 00007 #include "Rivet/Math/Vector3.hh" 00008 00009 namespace Rivet { 00010 00011 00012 /// @brief Specialisation of MatrixN to aid 3 dimensional rotations. 00013 class Matrix3 : public Matrix<3> { 00014 public: 00015 Matrix3() { } 00016 00017 Matrix3(const Matrix<3>& m3) : Matrix<3>::Matrix(m3) { } 00018 00019 Matrix3(const Vector3& axis, const double angle) { 00020 const Vector3 normaxis = axis.unit(); 00021 _matrix.loadRotation3(angle, normaxis._vec); 00022 } 00023 00024 Matrix3(const Vector3& from, const Vector3& to) { 00025 setAsRotation(from, to); 00026 } 00027 00028 static Matrix3 mkXRotation(const double angle) { 00029 return Matrix3(Vector3(1,0,0), angle); 00030 } 00031 00032 static Matrix3 mkYRotation(const double angle) { 00033 return Matrix3(Vector3(0,1,0), angle); 00034 } 00035 00036 static Matrix3 mkZRotation(const double angle) { 00037 return Matrix3(Vector3(0,0,1), angle); 00038 } 00039 00040 Matrix3& setAsRotation(const Vector3& from, const Vector3& to) { 00041 const double theta = angle(from, to); 00042 if (Rivet::isZero(theta)) { 00043 _matrix.loadIdentity(); 00044 } else { 00045 const Vector3 normaxis = cross(from, to).unit(); 00046 _matrix.loadRotation3(theta, normaxis._vec); 00047 } 00048 return *this; 00049 } 00050 00051 }; 00052 00053 00054 } 00055 00056 #endif Generated on Tue Dec 13 2016 16:32:38 for The Rivet MC analysis system by ![]() |