AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
float_math.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17/*
18This source code has been taken and modified by Algoryx Simulation AB
19from the source and under the license given below.
20*/
22
23#ifndef FLOAT_MATH_H
24
25#define FLOAT_MATH_H
26
27namespace ConvexDecomposition
28{
29
86 // a set of routines that let you do common 3d math
87 // operations without any vector, matrix, or quaternion
88 // classes or templates.
89 //
90 // a vector (or point) is a 'double *' to 3 doubling point numbers.
91 // a matrix is a 'double *' to an array of 16 doubling point numbers representing a 4x4 transformation matrix compatible with D3D or OGL
92 // a quaternion is a 'double *' to 4 doubles representing a quaternion x,y,z,w
93 //
94 //
95 //
96 // Please email bug fixes or improvements to John W. Ratcliff at mailto:jratcliff@infiniplex.net
97 //
98 // If you find this source code useful donate a couple of bucks to my kid's fund raising website at
99 // www.amillionpixels.us
100 //
101 // More snippets at: www.codesuppository.com
102 //
103
104 const double FM_PI = 3.141592654f;
105 const double FM_DEG_TO_RAD = ((2.0f * FM_PI) / 360.0f);
106 const double FM_RAD_TO_DEG = (360.0f / (2.0f * FM_PI));
107
108 void fm_identity(double *matrix); // set 4x4 matrix to identity.
109 void fm_inverseRT(const double *matrix,const double *pos,double *t); // inverse rotate translate the point.
110 void fm_transform(const double *matrix,const double *pos,double *t); // rotate and translate this point.
111 void fm_rotate(const double *matrix,const double *pos,double *t); // only rotate the point by a 4x4 matrix, don't translate.
112 void fm_eulerMatrix(double ax,double ay,double az,double *matrix); // convert Euler (in radians) to a dest 4x4 matrix (translation set to zero)
113 void fm_getAABB(unsigned int vcount,const double *points,unsigned int pstride,double *bmin,double *bmax);
114 void fm_eulerToQuat(double roll,double pitch,double yaw,double *quat); // convert Euler angles to quaternion.
115 void fm_quatToMatrix(const double *quat,double *matrix); // convert quaternion rotation to matrix, translation set to zero.
116 void fm_quatRotate(const double *quat,const double *v,double *r); // rotate a vector directly by a quaternion.
117 void fm_getTranslation(const double *matrix,double *t);
118 void fm_matrixToQuat(const double *matrix,double *quat); // convert the 3x3 portion of a 4x4 matrix into a quaternion as x,y,z,w
119 double fm_sphereVolume(double radius); // return's the volume of a sphere of this radius (4/3 PI * R cubed )
120 double fm_cylinderVolume(double radius,double h);
121 double fm_capsuleVolume(double radius,double h);
122 double fm_distance(const double *p1,const double *p2);
123 double fm_distanceSquared(const double *p1,const double *p2);
124 double fm_computePlane(const double *p1,const double *p2,const double *p3,double *n); // return D
125 double fm_distToPlane(const double *plane,const double *pos); // computes the distance of this point from the plane.
126 double fm_dot(const double *p1,const double *p2);
127 void fm_cross(double *cross,const double *a,const double *b);
128 void fm_computeNormalVector(double *n,const double *p1,const double *p2); // as P2-P1 normalized.
129 bool fm_computeWindingOrder(const double *p1,const double *p2,const double *p3); // returns true if the triangle is clockwise.
130 void fm_normalize(double *n); // normalize this vector
131
132} // end of namespace
133
134#endif