Rivet
1.8.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
include
Rivet
Math
Matrix3.hh
1
#ifndef RIVET_MATH_MATRIX3
2
#define RIVET_MATH_MATRIX3
3
4
#include "Rivet/Math/MathHeader.hh"
5
#include "Rivet/Math/MathUtils.hh"
6
#include "Rivet/Math/MatrixN.hh"
7
#include "Rivet/Math/Vector3.hh"
8
9
namespace
Rivet {
10
11
13
class
Matrix3
:
public
Matrix
<3> {
14
public
:
15
Matrix3
() { }
16
17
Matrix3
(
const
Matrix<3>
& m3) :
Matrix<3>::Matrix
(m3) { }
18
19
Matrix3
(
const
Vector3
& axis,
const
double
angle
) {
20
const
Vector3
normaxis = axis.
unit
();
21
_matrix.loadRotation3(angle, normaxis._vec);
22
}
23
24
Matrix3
(
const
Vector3
& from,
const
Vector3
& to) {
25
setAsRotation(from, to);
26
}
27
28
public
:
29
static
Matrix3
mkXRotation(
const
double
angle) {
30
return
Matrix3
(
Vector3
(1,0,0), angle);
31
}
32
33
static
Matrix3
mkYRotation(
const
double
angle) {
34
return
Matrix3
(
Vector3
(0,1,0), angle);
35
}
36
37
static
Matrix3
mkZRotation(
const
double
angle) {
38
return
Matrix3
(
Vector3
(0,0,1), angle);
39
}
40
41
public
:
42
Matrix3
& setAsRotation(
const
Vector3
& from,
const
Vector3
& to) {
43
const
double
theta
=
angle
(from, to);
44
if
(
Rivet::isZero
(theta)) {
45
_matrix.loadIdentity();
46
}
else
{
47
const
Vector3
normaxis = cross(from, to).
unit
();
48
_matrix.loadRotation3(theta, normaxis._vec);
49
}
50
return
*
this
;
51
}
52
53
};
54
55
56
}
57
58
#endif
Generated on Wed May 8 2013 17:45:40 for Rivet by
1.8.3.1