#include <cmath>
#include <cml/cml.h>
+#include <Moof/OpenGL.hh> // GLscalar
+
namespace Mf {
-// Basic types.
+typedef GLscalar Scalar;
+
+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>,
+ cml::col_basis, cml::col_major > Matrix4;
+
+typedef cml::quaternion< Scalar, cml::fixed<>, cml::vector_first,
+ cml::positive_cross > Quaternion;
-typedef float Scalar; ///< Scalar type.
+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;
+}
-typedef cml::vector2f Vector2;
-typedef cml::vector3f Vector3;
-typedef cml::vector4f Vector4;
+inline Vector2& demoteVector(Vector2& left, const Vector3& right)
+{
+ left[0] = right[0];
+ left[1] = right[1];
+ return left;
+}
-typedef cml::matrix33f_c Matrix3;
-typedef cml::matrix44f_c Matrix4;
+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;
+}
-typedef cml::quaternionf_p Quaternion;
+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;
+}
-typedef Vector4 Color;
-const Scalar EPSILON = 0.000001f;
+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;
}