float_math.h
Go to the documentation of this file.
1 #ifndef FLOAT_MATH_H
2 
3 #define FLOAT_MATH_H
4 
5 namespace ConvexDecomposition
6 {
7 
64 // a set of routines that let you do common 3d math
65 // operations without any vector, matrix, or quaternion
66 // classes or templates.
67 //
68 // a vector (or point) is a 'double *' to 3 doubleing point numbers.
69 // a matrix is a 'double *' to an array of 16 doubleing point numbers representing a 4x4 transformation matrix compatible with D3D or OGL
70 // a quaternion is a 'double *' to 4 doubles representing a quaternion x,y,z,w
71 //
72 //
73 //
74 // Please email bug fixes or improvements to John W. Ratcliff at mailto:jratcliff@infiniplex.net
75 //
76 // If you find this source code useful donate a couple of bucks to my kid's fund raising website at
77 // www.amillionpixels.us
78 //
79 // More snippets at: www.codesuppository.com
80 //
81 
82 const double FM_PI = 3.141592654f;
83 const double FM_DEG_TO_RAD = ((2.0f * FM_PI) / 360.0f);
84 const double FM_RAD_TO_DEG = (360.0f / (2.0f * FM_PI));
85 
86 void fm_identity(double *matrix); // set 4x4 matrix to identity.
87 void fm_inverseRT(const double *matrix,const double *pos,double *t); // inverse rotate translate the point.
88 void fm_transform(const double *matrix,const double *pos,double *t); // rotate and translate this point.
89 void fm_rotate(const double *matrix,const double *pos,double *t); // only rotate the point by a 4x4 matrix, don't translate.
90 void fm_eulerMatrix(double ax,double ay,double az,double *matrix); // convert euler (in radians) to a dest 4x4 matrix (translation set to zero)
91 void fm_getAABB(unsigned int vcount,const double *points,unsigned int pstride,double *bmin,double *bmax);
92 void fm_eulerToQuat(double roll,double pitch,double yaw,double *quat); // convert euler angles to quaternion.
93 void fm_quatToMatrix(const double *quat,double *matrix); // convert quaterinion rotation to matrix, translation set to zero.
94 void fm_quatRotate(const double *quat,const double *v,double *r); // rotate a vector directly by a quaternion.
95 void fm_getTranslation(const double *matrix,double *t);
96 void fm_matrixToQuat(const double *matrix,double *quat); // convert the 3x3 portion of a 4x4 matrix into a quaterion as x,y,z,w
97 double fm_sphereVolume(double radius); // return's the volume of a sphere of this radius (4/3 PI * R cubed )
98 double fm_cylinderVolume(double radius,double h);
99 double fm_capsuleVolume(double radius,double h);
100 double fm_distance(const double *p1,const double *p2);
101 double fm_distanceSquared(const double *p1,const double *p2);
102 double fm_computePlane(const double *p1,const double *p2,const double *p3,double *n); // return D
103 double fm_distToPlane(const double *plane,const double *pos); // computes the distance of this point from the plane.
104 double fm_dot(const double *p1,const double *p2);
105 void fm_cross(double *cross,const double *a,const double *b);
106 void fm_computeNormalVector(double *n,const double *p1,const double *p2); // as P2-P1 normalized.
107 bool fm_computeWindingOrder(const double *p1,const double *p2,const double *p3); // returns true if the triangle is clockwise.
108 void fm_normalize(double *n); // normalize this vector
109 
110 }; // end of nsamepace
111 
112 #endif
ConvexDecomposition::fm_matrixToQuat
void fm_matrixToQuat(const double *matrix, double *quat)
Definition: float_math.cpp:251
ConvexDecomposition::fm_cross
void fm_cross(double *cross, const double *a, const double *b)
Definition: float_math.cpp:407
ConvexDecomposition::fm_getTranslation
void fm_getTranslation(const double *matrix, double *t)
Definition: float_math.cpp:244
ConvexDecomposition::fm_normalize
void fm_normalize(double *n)
Definition: float_math.cpp:448
ConvexDecomposition::fm_distToPlane
double fm_distToPlane(const double *plane, const double *p)
Definition: float_math.cpp:397
ConvexDecomposition::fm_quatRotate
void fm_quatRotate(const double *quat, const double *v, double *r)
Definition: float_math.cpp:228
ConvexDecomposition::fm_rotate
void fm_rotate(const double *matrix, const double *v, double *t)
Definition: float_math.cpp:331
ConvexDecomposition::fm_quatToMatrix
void fm_quatToMatrix(const double *quat, double *matrix)
Definition: float_math.cpp:190
ConvexDecomposition::fm_sphereVolume
double fm_sphereVolume(double radius)
Definition: float_math.cpp:302
ConvexDecomposition::FM_PI
const double FM_PI
Definition: float_math.h:82
ConvexDecomposition
Definition: bestfit.cpp:75
ConvexDecomposition::fm_dot
double fm_dot(const double *p1, const double *p2)
Definition: float_math.cpp:402
ConvexDecomposition::fm_inverseRT
void fm_inverseRT(const double *matrix, const double *pos, double *t)
Definition: float_math.cpp:86
ConvexDecomposition::fm_identity
void fm_identity(double *matrix)
Definition: float_math.cpp:102
ConvexDecomposition::FM_RAD_TO_DEG
const double FM_RAD_TO_DEG
Definition: float_math.h:84
ConvexDecomposition::fm_distance
double fm_distance(const double *p1, const double *p2)
Definition: float_math.cpp:339
ConvexDecomposition::fm_computeNormalVector
void fm_computeNormalVector(double *n, const double *p1, const double *p2)
Definition: float_math.cpp:414
ConvexDecomposition::fm_transform
void fm_transform(const double *matrix, const double *v, double *t)
Definition: float_math.cpp:324
ConvexDecomposition::fm_getAABB
void fm_getAABB(unsigned int vcount, const double *points, unsigned int pstride, double *bmin, double *bmax)
Definition: float_math.cpp:134
ConvexDecomposition::fm_cylinderVolume
double fm_cylinderVolume(double radius, double h)
Definition: float_math.cpp:308
ConvexDecomposition::cross
double3 cross(const double3 &a, const double3 &b)
Definition: cd_hull.cpp:672
ConvexDecomposition::fm_eulerMatrix
void fm_eulerMatrix(double ax, double ay, double az, double *matrix)
Definition: float_math.cpp:127
ConvexDecomposition::fm_eulerToQuat
void fm_eulerToQuat(double roll, double pitch, double yaw, double *quat)
Definition: float_math.cpp:165
ConvexDecomposition::plane
Definition: planetri.cpp:182
ConvexDecomposition::FM_DEG_TO_RAD
const double FM_DEG_TO_RAD
Definition: float_math.h:83
ConvexDecomposition::fm_computePlane
double fm_computePlane(const double *A, const double *B, const double *C, double *n)
Definition: float_math.cpp:358
ConvexDecomposition::fm_distanceSquared
double fm_distanceSquared(const double *p1, const double *p2)
Definition: float_math.cpp:348
ConvexDecomposition::fm_capsuleVolume
double fm_capsuleVolume(double radius, double h)
Definition: float_math.cpp:313
ConvexDecomposition::fm_computeWindingOrder
bool fm_computeWindingOrder(const double *p1, const double *p2, const double *p3)
Definition: float_math.cpp:422


convex_decomposition
Author(s): John W. Ratcliff
autogenerated on Wed Mar 2 2022 00:04:59