]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Math.hh
new level-based controllers
[chaz/yoink] / src / Moof / Math.hh
index c4e3484ebebc56b5bad7e05cee6c13f9ef657557..eb411e06d3299d90778117bafe81b08061c343ad 100644 (file)
@@ -49,6 +49,8 @@ typedef cml::vector< Scalar, cml::fixed<2> >  Vector2;
 typedef cml::vector< Scalar, cml::fixed<3> >   Vector3;
 typedef cml::vector< Scalar, cml::fixed<4> >   Vector4;
 
+typedef cml::matrix< Scalar, cml::fixed<2,2>,
+               cml::col_basis, cml::col_major >                Matrix2;
 typedef cml::matrix< Scalar, cml::fixed<3,3>,
                cml::col_basis, cml::col_major >                Matrix3;
 typedef cml::matrix< Scalar, cml::fixed<4,4>,
@@ -57,6 +59,42 @@ typedef cml::matrix< Scalar, cml::fixed<4,4>,
 typedef cml::quaternion< Scalar, cml::fixed<>, cml::vector_first,
                cml::positive_cross >                                   Quaternion;
 
+typedef cml::constants<Scalar>                                 Constants;
+
+
+inline Vector3& demoteVector(Vector3& left, const Vector4& right)
+{
+       left[0] = right[0];
+       left[1] = right[1];
+       left[2] = right[2];
+       return left;
+}
+
+inline Vector2& demoteVector(Vector2& left, const Vector3& right)
+{
+       left[0] = right[0];
+       left[1] = right[1];
+       return left;
+}
+
+inline Vector4& promoteVector(Vector4& left, const Vector3& right, Scalar extra = 1.0)
+{
+       left[0] = right[0];
+       left[1] = right[1];
+       left[2] = right[2];
+       left[3] = extra;
+       return left;
+}
+
+inline Vector3& promoteVector(Vector3& left, const Vector2& right, Scalar extra = 1.0)
+{
+       left[0] = right[0];
+       left[1] = right[1];
+       left[3] = extra;
+       return left;
+}
+
+
 
 const Scalar EPSILON = 0.000001;
 
@@ -64,7 +102,7 @@ const Scalar EPSILON = 0.000001;
  * Check the equality of scalars with a certain degree of error allowed.
  */
 
-inline bool checkEquality(Scalar a, Scalar b, Scalar epsilon = EPSILON)
+inline bool isEqual(Scalar a, Scalar b, Scalar epsilon = EPSILON)
 {
        return std::abs(a - b) < epsilon;
 }
This page took 0.024304 seconds and 4 git commands to generate.