-
Notifications
You must be signed in to change notification settings - Fork 0
/
EigenTools.cpp
71 lines (54 loc) · 1.59 KB
/
EigenTools.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
//////
//
// Includes
//
// Eigen library
#include <Eigen/Geometry>
// Implemented header
#include "EigenTools.h"
//////
//
// Class implementation
//
// EigenHelper
//
template <class flt_type>
typename EigenTypes<flt_type>::Mat4 EigenHelper<flt_type>::rotate44(
const typename EigenTypes<flt_type>::Vec3 &axis, flt_type angle
)
{
// Prepare transformation data as per Eigen API specs
Eigen::Transform<flt_type, 3, Eigen::Affine> rot;
rot = Eigen::AngleAxis<flt_type>(angle, axis);
// Return as 4x4 homogenous matrix
return std::move(EigenTypes<flt_type>::Mat4(rot.data()));
}
template <class flt_type>
typename EigenTypes<flt_type>::Mat4 EigenHelper<flt_type>::translate44(
const typename EigenTypes<flt_type>::Vec3 &vector
)
{
// Prepare transformation data as per Eigen API specs
Eigen::Transform<flt_type, 3, Eigen::Affine> transl;
transl = Eigen::Translation<flt_type, 3>(vector);
// Return as 4x4 homogenous matrix
return std::move(EigenTypes<flt_type>::Mat4(transl.data()));
}
template <class flt_type>
typename EigenTypes<flt_type>::Mat4 EigenHelper<flt_type>::translate44(
flt_type x, flt_type y, flt_type z
)
{
// Prepare transformation data as per Eigen API specs
Eigen::Transform<flt_type, 3, Eigen::Affine> transl;
transl = Eigen::Translation<flt_type, 3>(EigenTypes<flt_type>::Vec3(x, y, z));
// Return as 4x4 homogenous matrix
return std::move(EigenTypes<flt_type>::Mat4(transl.data()));
}
//////
//
// Explicit template instantiations
//
// Only floating point and some integer variants are intended
template APISPEC EigenHelper<float>;
template APISPEC EigenHelper<double>;