float_math.h
Go to the documentation of this file.
00001 #ifndef FLOAT_MATH_H
00002 
00003 #define FLOAT_MATH_H
00004 
00005 namespace ConvexDecomposition
00006 {
00007 
00064 // a set of routines that let you do common 3d math
00065 // operations without any vector, matrix, or quaternion
00066 // classes or templates.
00067 //
00068 // a vector (or point) is a 'double *' to 3 doubleing point numbers.
00069 // a matrix is a 'double *' to an array of 16 doubleing point numbers representing a 4x4 transformation matrix compatible with D3D or OGL
00070 // a quaternion is a 'double *' to 4 doubles representing a quaternion x,y,z,w
00071 //
00072 //
00073 //
00074 // Please email bug fixes or improvements to John W. Ratcliff at mailto:jratcliff@infiniplex.net
00075 //
00076 // If you find this source code useful donate a couple of bucks to my kid's fund raising website at
00077 //  www.amillionpixels.us
00078 //
00079 // More snippets at: www.codesuppository.com
00080 //
00081 
00082 const double FM_PI = 3.141592654f;
00083 const double FM_DEG_TO_RAD = ((2.0f * FM_PI) / 360.0f);
00084 const double FM_RAD_TO_DEG = (360.0f / (2.0f * FM_PI));
00085 
00086 void  fm_identity(double *matrix); // set 4x4 matrix to identity.
00087 void  fm_inverseRT(const double *matrix,const double *pos,double *t); // inverse rotate translate the point.
00088 void  fm_transform(const double *matrix,const double *pos,double *t); // rotate and translate this point.
00089 void  fm_rotate(const double *matrix,const double *pos,double *t); // only rotate the point by a 4x4 matrix, don't translate.
00090 void  fm_eulerMatrix(double ax,double ay,double az,double *matrix); // convert euler (in radians) to a dest 4x4 matrix (translation set to zero)
00091 void  fm_getAABB(unsigned int vcount,const double *points,unsigned int pstride,double *bmin,double *bmax);
00092 void  fm_eulerToQuat(double roll,double pitch,double yaw,double *quat); // convert euler angles to quaternion.
00093 void  fm_quatToMatrix(const double *quat,double *matrix); // convert quaterinion rotation to matrix, translation set to zero.
00094 void  fm_quatRotate(const double *quat,const double *v,double *r); // rotate a vector directly by a quaternion.
00095 void  fm_getTranslation(const double *matrix,double *t);
00096 void  fm_matrixToQuat(const double *matrix,double *quat); // convert the 3x3 portion of a 4x4 matrix into a quaterion as x,y,z,w
00097 double fm_sphereVolume(double radius); // return's the volume of a sphere of this radius (4/3 PI * R cubed )
00098 double fm_cylinderVolume(double radius,double h);
00099 double fm_capsuleVolume(double radius,double h);
00100 double fm_distance(const double *p1,const double *p2);
00101 double fm_distanceSquared(const double *p1,const double *p2);
00102 double fm_computePlane(const double *p1,const double *p2,const double *p3,double *n); // return D
00103 double fm_distToPlane(const double *plane,const double *pos); // computes the distance of this point from the plane.
00104 double fm_dot(const double *p1,const double *p2);
00105 void  fm_cross(double *cross,const double *a,const double *b);
00106 void  fm_computeNormalVector(double *n,const double *p1,const double *p2); // as P2-P1 normalized.
00107 bool  fm_computeWindingOrder(const double *p1,const double *p2,const double *p3); // returns true if the triangle is clockwise.
00108 void  fm_normalize(double *n); // normalize this vector
00109 
00110 }; // end of nsamepace
00111 
00112 #endif


convex_decomposition
Author(s): John W. Ratcliff
autogenerated on Sat Jun 8 2019 20:01:17