#include <math.h>
Include dependency graph for mathlib.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Defines | |
| #define | DEG2RAD(a) ( ( (a) * Q_PI ) / 180.0F ) |
| #define | DotProduct(x, y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) |
| #define | EQUAL_EPSILON 0.001 |
| #define | PLANE_NON_AXIAL 3 |
| #define | PLANE_X 0 |
| #define | PLANE_Y 1 |
| #define | PLANE_Z 2 |
| #define | Q_PI 3.14159265358979323846 |
| #define | RAD2DEG(a) ( ( (a) * 180.0f ) / Q_PI ) |
| #define | SIDE_BACK 1 |
| #define | SIDE_CROSS -2 |
| #define | SIDE_FRONT 0 |
| #define | SIDE_ON 2 |
| #define | VectorAdd(a, b, c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} |
| #define | VectorClear(x) {x[0] = x[1] = x[2] = 0;} |
| #define | VectorCopy(a, b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} |
| #define | VectorNegate(x) {x[0]=-x[0];x[1]=-x[1];x[2]=-x[2];} |
| #define | VectorScale(a, b, c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];} |
| #define | VectorSubtract(a, b, c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} |
Typedefs | |
| typedef vec_t | vec2_t [3] |
| typedef vec_t | vec3_t [3] |
| typedef vec_t | vec4_t [4] |
| typedef float | vec_t |
Functions | |
| vec_t | _DotProduct (vec3_t v1, vec3_t v2) |
| void | _VectorAdd (vec3_t va, vec3_t vb, vec3_t out) |
| void | _VectorCopy (vec3_t in, vec3_t out) |
| void | _VectorScale (vec3_t v, vec_t scale, vec3_t out) |
| void | _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out) |
| void | AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs) |
| void | ClearBounds (vec3_t mins, vec3_t maxs) |
| vec_t | ColorNormalize (const vec3_t in, vec3_t out) |
| void | CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross) |
| void | NormalToLatLong (const vec3_t normal, byte bytes[2]) |
| qboolean | PlaneFromPoints (vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c) |
| int | PlaneTypeForNormal (vec3_t normal) |
| vec_t | Q_rint (vec_t in) |
| void | Vec10Copy (vec_t *in, vec_t *out) |
| qboolean | VectorCompare (const vec3_t v1, const vec3_t v2) |
| void | VectorInverse (vec3_t v) |
| double | VectorLength (const vec3_t v) |
| void | VectorMA (const vec3_t va, double scale, const vec3_t vb, vec3_t vc) |
| vec_t | VectorNormalize (const vec3_t in, vec3_t out) |
Variables | |
| vec3_t | vec3_origin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||||||||||||
|
Definition at line 170 of file l_math.c.
|
|
||||||||||||||||
|
Definition at line 182 of file l_math.c.
|
|
||||||||||||
|
Definition at line 189 of file l_math.c.
|
|
||||||||||||||||
|
Definition at line 196 of file l_math.c. References v. 00197 {
00198 out[0] = v[0] * scale;
00199 out[1] = v[1] * scale;
00200 out[2] = v[2] * scale;
00201 }
|
|
||||||||||||||||
|
Definition at line 175 of file l_math.c.
|
|
||||||||||||||||
|
Definition at line 276 of file l_math.c. 00277 {
00278 int i;
00279 vec_t val;
00280
00281 for (i=0 ; i<3 ; i++)
00282 {
00283 val = v[i];
00284 if (val < mins[i])
00285 mins[i] = val;
00286 if (val > maxs[i])
00287 maxs[i] = val;
00288 }
00289 }
|
|
||||||||||||
|
Definition at line 270 of file l_math.c. 00271 {
00272 mins[0] = mins[1] = mins[2] = 99999;
00273 maxs[0] = maxs[1] = maxs[2] = -99999;
00274 }
|
|
||||||||||||
|
Definition at line 241 of file l_math.c. References in, max, vec_t, and VectorScale. Referenced by CreateEntityLights(), LoadShaderImage(), VL_CreateEntityLights(), VL_SurfaceRadiosity(), VS_CreateEntitySpeakers(), and VS_SurfaceRadiosity(). 00242 {
00243 float max, scale;
00244
00245 max = in[0];
00246 if (in[1] > max)
00247 max = in[1];
00248 if (in[2] > max)
00249 max = in[2];
00250
00251 if (max == 0)
00252 return 0;
00253
00254 scale = 1.0 / max;
00255
00256 VectorScale (in, scale, out);
00257
00258 return max;
00259 }
|
|
||||||||||||||||
|
Definition at line 156 of file l_math.c. 00157 {
00158 cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
00159 cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
00160 cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
00161 }
|
|
||||||||||||
|
Definition at line 44 of file mathlib.c. References a, acos(), atan2(), b, byte, and RAD2DEG. Referenced by TraceGrid(). 00044 {
00045 // check for singularities
00046 if ( normal[0] == 0 && normal[1] == 0 ) {
00047 if ( normal[2] > 0 ) {
00048 bytes[0] = 0;
00049 bytes[1] = 0; // lat = 0, long = 0
00050 } else {
00051 bytes[0] = 128;
00052 bytes[1] = 0; // lat = 0, long = 128
00053 }
00054 } else {
00055 int a, b;
00056
00057 a = RAD2DEG( atan2( normal[1], normal[0] ) ) * (255.0f / 360.0f );
00058 a &= 0xff;
00059
00060 b = RAD2DEG( acos( normal[2] ) ) * ( 255.0f / 360.0f );
00061 b &= 0xff;
00062
00063 bytes[0] = b; // longitude
00064 bytes[1] = a; // lattitude
00065 }
00066 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 320 of file q_math.c. References a, b, c, CrossProduct(), DotProduct, qboolean, vec3_t, VectorNormalize(), and VectorSubtract. Referenced by CM_GenerateFacetFor3Points(), CM_GenerateFacetFor4Points(), EmitTerrainVerts2(), Q2_ParseBrush(), and R_PlaneForSurface(). 00320 {
00321 vec3_t d1, d2;
00322
00323 VectorSubtract( b, a, d1 );
00324 VectorSubtract( c, a, d2 );
00325 CrossProduct( d2, d1, plane );
00326 if ( VectorNormalize( plane ) == 0 ) {
00327 return qfalse;
00328 }
00329
00330 plane[3] = DotProduct( a, plane );
00331 return qtrue;
00332 }
|
Here is the call graph for this function:

|
|
Definition at line 101 of file map.c. 00102 {
00103 vec_t ax, ay, az;
00104
00105 // NOTE: should these have an epsilon around 1.0?
00106 if (normal[0] == 1.0 || normal[0] == -1.0)
00107 return PLANE_X;
00108 if (normal[1] == 1.0 || normal[1] == -1.0)
00109 return PLANE_Y;
00110 if (normal[2] == 1.0 || normal[2] == -1.0)
00111 return PLANE_Z;
00112
00113 ax = fabs(normal[0]);
00114 ay = fabs(normal[1]);
00115 az = fabs(normal[2]);
00116
00117 if (ax >= ay && ax >= az)
00118 return PLANE_ANYX;
00119 if (ay >= ax && ay >= az)
00120 return PLANE_ANYY;
00121 return PLANE_ANYZ;
00122 } //end of the function PlaneTypeForNormal
|
|
|
Definition at line 151 of file l_math.c. 00152 {
00153 return floor(in + 0.5);
00154 }
|
|
||||||||||||
|
Definition at line 115 of file mathlib.c. References in. 00115 {
00116 out[0] = in[0];
00117 out[1] = in[1];
00118 out[2] = in[2];
00119 out[3] = in[3];
00120 out[4] = in[4];
00121 out[5] = in[5];
00122 out[6] = in[6];
00123 out[7] = in[7];
00124 out[8] = in[8];
00125 out[9] = in[9];
00126 }
|
|
||||||||||||
|
Definition at line 140 of file l_math.c. 00141 {
00142 int i;
00143
00144 for (i=0 ; i<3 ; i++)
00145 if (fabs(v1[i]-v2[i]) > EQUAL_EPSILON)
00146 return false;
00147
00148 return true;
00149 }
|
|
|
Definition at line 263 of file l_math.c.
|
|
|
Definition at line 127 of file l_math.c. 00128 {
00129 int i;
00130 double length;
00131
00132 length = 0;
00133 for (i=0 ; i< 3 ; i++)
00134 length += v[i]*v[i];
00135 length = sqrt (length); // FIXME
00136
00137 return length;
00138 }
|
|
||||||||||||||||||||
|
Definition at line 163 of file mathlib.c. References va(). 00163 {
00164 vc[0] = va[0] + scale*vb[0];
00165 vc[1] = va[1] + scale*vb[1];
00166 vc[2] = va[2] + scale*vb[2];
00167 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 208 of file mathlib.c. References in, length(), sqrt(), vec_t, and VectorClear. 00208 {
00209 vec_t length, ilength;
00210
00211 length = sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]);
00212 if (length == 0)
00213 {
00214 VectorClear (out);
00215 return 0;
00216 }
00217
00218 ilength = 1.0/length;
00219 out[0] = in[0]*ilength;
00220 out[1] = in[1]*ilength;
00221 out[2] = in[2]*ilength;
00222
00223 return length;
00224 }
|
Here is the call graph for this function:

|
|
|
1.3.9.1