aboutsummaryrefslogtreecommitdiff
path: root/include/fml
diff options
context:
space:
mode:
Diffstat (limited to 'include/fml')
-rw-r--r--include/fml/quat.h6
-rw-r--r--include/fml/vec3.h10
2 files changed, 15 insertions, 1 deletions
diff --git a/include/fml/quat.h b/include/fml/quat.h
index 14c966e..67a89d5 100644
--- a/include/fml/quat.h
+++ b/include/fml/quat.h
@@ -15,11 +15,15 @@ namespace fml {
quat(vec3 vec);
quat();
- operator vec3();
+ operator vec3() const;
quat conjugate() const;
+ /* returns <cos / 2, x * sin / 2, y * sin / 2, z * sin / 2> */
static quat from_angleaxis(scalar angle, vec3 axis);
+
+ /* returns rotquat * this * rotquat.conj */
+ quat rotateby(const quat &rotquat) const;
};
quat operator*(const quat &, const quat &);
diff --git a/include/fml/vec3.h b/include/fml/vec3.h
index 3460c56..a006619 100644
--- a/include/fml/vec3.h
+++ b/include/fml/vec3.h
@@ -5,6 +5,8 @@
#include "fml.h"
namespace fml {
+ class quat;
+
class vec3 {
public:
scalar v[3];
@@ -27,7 +29,15 @@ namespace fml {
scalar magnitudeSquared() const;
vec3 normalize() const;
scalar dot(const vec3 &other) const;
+
+ /* order is this x other. */
vec3 cross(const vec3 &other) const;
+
+ /* rotate by a rotation quaternion */
+ vec3 rotateby(const quat &rotquat) const;
+
+ /* return an arbitrary unit vector normal to other */
+ static vec3 any_unit_normal(const vec3 &other);
};
vec3 operator*(scalar scale, const vec3 &v);