/usr/include/Rivet/Math/Matrix3.hh is in librivet-dev 1.8.3-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #ifndef RIVET_MATH_MATRIX3
#define RIVET_MATH_MATRIX3
#include "Rivet/Math/MathHeader.hh"
#include "Rivet/Math/MathUtils.hh"
#include "Rivet/Math/MatrixN.hh"
#include "Rivet/Math/Vector3.hh"
namespace Rivet {
/// @brief Specialisation of MatrixN to aid 3 dimensional rotations.
class Matrix3 : public Matrix<3> {
public:
Matrix3() { }
Matrix3(const Matrix<3>& m3) : Matrix<3>::Matrix(m3) { }
Matrix3(const Vector3& axis, const double angle) {
const Vector3 normaxis = axis.unit();
_matrix.loadRotation3(angle, normaxis._vec);
}
Matrix3(const Vector3& from, const Vector3& to) {
setAsRotation(from, to);
}
public:
static Matrix3 mkXRotation(const double angle) {
return Matrix3(Vector3(1,0,0), angle);
}
static Matrix3 mkYRotation(const double angle) {
return Matrix3(Vector3(0,1,0), angle);
}
static Matrix3 mkZRotation(const double angle) {
return Matrix3(Vector3(0,0,1), angle);
}
public:
Matrix3& setAsRotation(const Vector3& from, const Vector3& to) {
const double theta = angle(from, to);
if (Rivet::isZero(theta)) {
_matrix.loadIdentity();
} else {
const Vector3 normaxis = cross(from, to).unit();
_matrix.loadRotation3(theta, normaxis._vec);
}
return *this;
}
};
}
#endif
|