#ifndef ICL_GEOM_DEFS_H #define ICL_GEOM_DEFS_H #include #include #include #include namespace icl{ /// Matrix Typedef of float matrices typedef FixedMatrix Mat4D32f; /// Matrix Typedef of double matrices typedef FixedMatrix Mat4D64f; /// Vector typedef of float vectors typedef FixedColVector Vec4D32f; /// Vector typedef of double vectors typedef FixedColVector Vec4D64f; /// Short typedef for 4D float vectors typedef Vec4D32f Vec; /// Short typedef for 4D float matrices typedef Mat4D32f Mat; /// normalize a vector to length 1 template inline FixedColVector normalize(const FixedMatrix &v) { double l = v.length(); ICLASSERT_RETURN_VAL(l,v); return v/l; } /// homogenize a vector be normalizing 4th component to 1 template inline FixedColVector homogenize(const FixedMatrix &v){ ICLASSERT_RETURN_VAL(v[3],v); return v/v[3]; } /// perform perspective projection template inline FixedColVector project(FixedMatrix v, T z){ T zz = z*v[2]; v[0]/=zz; v[1]/=zz; v[2]=0; v[3]=1; return v; } /// homogeneous 3D cross-product template inline FixedColVector cross(const FixedMatrix &v1, const FixedMatrix &v2){ return FixedColVector(v1[1]*v2[2]-v1[2]*v2[1], v1[2]*v2[0]-v1[0]*v2[2], v1[0]*v2[1]-v1[1]*v2[0], 1 ); } typedef std::vector VecArray; } #endif