]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Math.hh
beginning CD implementation
[chaz/yoink] / src / Moof / Math.hh
index c4e3484ebebc56b5bad7e05cee6c13f9ef657557..6665a195bc0341f0acb629d4e036bea95efd0c19 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,30 @@ 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 demote(const Vector4& vec)
+{
+       return Vector3(vec[0], vec[1], vec[2]);
+}
+
+inline Vector2 demote(const Vector3& vec)
+{
+       return Vector2(vec[0], vec[1]);
+}
+
+inline Vector4 promote(const Vector3& vec, Scalar extra = 1.0)
+{
+       return Vector4(vec[0], vec[1], vec[2], extra);
+}
+
+inline Vector3 promote(const Vector2& vec, Scalar extra = 1.0)
+{
+       return Vector3(vec[0], vec[1], extra);
+}
+
+
 
 const Scalar EPSILON = 0.000001;
 
@@ -64,7 +90,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.020853 seconds and 4 git commands to generate.