summary refs log tree commit diff
path: root/src/Transform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Transform.cpp')
-rw-r--r--src/Transform.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Transform.cpp b/src/Transform.cpp
new file mode 100644
index 0000000..72be8ea
--- /dev/null
+++ b/src/Transform.cpp
@@ -0,0 +1,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()};
+}
+
+}