blob: 72be8ea2720c312520b7329a20e6f990debea5f7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "Transform.hpp"
#include "Math/Common.hpp"
namespace MC {
Vector<3> Transform::forward() const {
return unit_vector({0, 0, 1});
}
Vector<3> Transform::right() const {
return unit_vector({1, 0, 0});
}
Vector<3> Transform::up() const {
return unit_vector({0, 1, 0});
}
Vector<3> Transform::unit_vector(Vector<3> axis) const {
auto rotation = Matrix<4, 4>::rotation(m_rotation);
auto result = rotation.transpose() * Vector<4>{axis.x(), axis.y(), axis.z(), 1.0f};
return {result.x(), result.y(), result.z()};
}
}
|