-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform.h
65 lines (51 loc) · 1.21 KB
/
transform.h
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
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include "commontype.h"
class Transform
{
public:
Transform(){
quatate_ = Quat (1,0,0,0);
translate_ = Vec3(0,0,0);
scale_ = 1.f;
}
Transform(const Quat & q, const Vec3 & p){
quatate_ = q;
translate_ = p;
scale_ = 1.f;
}
Transform(const Quat & q, const Vec3 & p, real_t s){
quatate_ = q;
translate_ = p;
scale_ = s;
}
void setTranslate(const Vec3 & pos ){
translate_ = pos;
}
void setScale(real_t s){
scale_ = s;
}
Vec3 operator * (const Vec3 & vec3){
Eigen::Isometry3f T = Eigen::Isometry3f::Identity();
T.rotate(quatate_.toRotationMatrix());
T.pretranslate(translate_);
// T.scale(scale_);
return T * vec3;
}
Mat4 ToMat4(){
Eigen::Isometry3f T = Eigen::Isometry3f::Identity();
T.rotate(quatate_.toRotationMatrix());
T.pretranslate(translate_);
// T.scale(scale_);
Mat4 mat =T.matrix();
return mat;
}
QMat4 toQMat4(){
return ToQType(ToMat4());
}
private:
Quat quatate_;
Vec3 translate_;
real_t scale_;
};
#endif // TRANSFORM_H