Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/axis.cc')
-rw-r--r--src/math/axis.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/math/axis.cc b/src/math/axis.cc
index 4d752bf..aa35d92 100644
--- a/src/math/axis.cc
+++ b/src/math/axis.cc
@@ -74,6 +74,23 @@ void Axis::change_roll(const float angle) {
axis_vector[1].assign(up);
}
+// perform a rotation about an arbitrary axis
+/* notes:
+ http://mathworld.wolfram.com/RotationFormula.html
+*/
+void Axis::rotate(Vector3f const &normal, float angle)
+{
+ float cosa = cosf(angle);
+ float sina = sinf(angle);
+
+ for (size_t i =0; i < 3; i++) {
+ axis_vector[i] =
+ axis_vector[i]*cosa +
+ normal * dotproduct(normal, axis_vector[i]) * (1 - cosa) +
+ crossproduct(axis_vector[i], normal)*sina;
+ }
+}
+
/*
Axis const Axis::transpose()
{