FS2_Open
Open source remastering of the Freespace 2 engine
vecmat.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _VECMAT_H
13 #define _VECMAT_H
14 
15 #include "globalincs/pstypes.h"
16 #include "math/floating.h"
17 
18 
19 #define vm_is_vec_nan(v) (_isnan((v)->xyz.x) || _isnan((v)->xyz.y) || _isnan((v)->xyz.z))
20 
21 //Macros/functions to fill in fields of structures
22 
23 //macro to check if vector is zero
24 #define IS_VEC_NULL_SQ_SAFE(v) ( ( (v)->xyz.x > -1e-16 ) && ( (v)->xyz.x < 1e-16 ) && \
25  ( (v)->xyz.y > -1e-16 ) && ( (v)->xyz.y < 1e-16 ) && \
26  ( (v)->xyz.z > -1e-16 ) && ( (v)->xyz.z < 1e-16 ) )
27 
28 #define IS_VEC_NULL(v) ( ( (v)->xyz.x > -1e-36 ) && ( (v)->xyz.x < 1e-36 ) && \
29  ( (v)->xyz.y > -1e-36 ) && ( (v)->xyz.y < 1e-36 ) && \
30  ( (v)->xyz.z > -1e-36 ) && ( (v)->xyz.z < 1e-36 ) )
31 
32 #define IS_MAT_NULL(v) (IS_VEC_NULL(&(v)->vec.fvec) && IS_VEC_NULL(&(v)->vec.uvec) && IS_VEC_NULL(&(v)->vec.rvec))
33 
34 //macro to set a vector to zero. we could do this with an in-line assembly
35 //macro, but it's probably better to let the compiler optimize it.
36 //Note: NO RETURN VALUE
37 #define vm_vec_zero(v) (v)->xyz.x=(v)->xyz.y=(v)->xyz.z=0.0f
38 
39 /*
40 //macro set set a matrix to the identity. Note: NO RETURN VALUE
41 #define vm_set_identity(m) do {m->rvec.x = m->uvec.y = m->fvec.z = (float)1.0; \
42  m->rvec.y = m->rvec.z = \
43  m->uvec.x = m->uvec.z = \
44  m->fvec.x = m->fvec.y = (float)0.0;} while (0)
45 */
46 extern void vm_set_identity(matrix *m);
47 
48 #define vm_vec_make(v,_x,_y,_z) ((v)->xyz.x=(_x), (v)->xyz.y=(_y), (v)->xyz.z=(_z))
49 
50 //Global constants
51 
52 extern vec3d vmd_zero_vector;
53 extern vec3d vmd_x_vector;
54 extern vec3d vmd_y_vector;
55 extern vec3d vmd_z_vector;
57 
58 //Here's a handy constant
59 
60 #define ZERO_VECTOR { { { 0.0f, 0.0f, 0.0f } } }
61 //#define IDENTITY_MATRIX {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
62 // first set of inside braces is for union, second set is for inside union, then for a2d[3][3] (some compiler warning messages just suck)
63 //#define IDENTITY_MATRIX { { { {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f, 1.0f} } } }
64 #define IDENTITY_MATRIX { { { { { { 1.0f, 0.0f, 0.0f } } }, { { { 0.0f, 1.0f, 0.0f } } }, { { { 0.0f, 0.0f, 1.0f } } } } } }
65 
66 //fills in fields of an angle vector
67 #define vm_angvec_make(v,_p,_b,_h) (((v)->p=(_p), (v)->b=(_b), (v)->h=(_h)), (v))
68 
69 //negate a vector
70 #define vm_vec_negate(v) do {(v)->xyz.x = - (v)->xyz.x; (v)->xyz.y = - (v)->xyz.y; (v)->xyz.z = - (v)->xyz.z;} while (0);
71 
72 typedef struct plane {
73  float A, B, C, D;
74 } plane;
75 
76 //Functions in library
77 
78 //adds two vectors, fills in dest, returns ptr to dest
79 //ok for dest to equal either source, but should use vm_vec_add2() if so
80 void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1);
81 
82 //adds src onto dest vector, returns ptr to dest
83 void vm_vec_add2(vec3d *dest, const vec3d *src);
84 
85 
86 //scales a vector and subs from to another
87 //dest -= k * src
88 void vm_vec_scale_sub2(vec3d *dest, const vec3d *src, float k);
89 
90 //subs two vectors, fills in dest, returns ptr to dest
91 //ok for dest to equal either source, but should use vm_vec_sub2() if so
92 void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1);
93 
94 
95 //subs one vector from another, returns ptr to dest
96 //dest can equal source
97 void vm_vec_sub2(vec3d *dest, const vec3d *src);
98 
99 //averages n vectors
100 vec3d *vm_vec_avg_n(vec3d *dest, int n, const vec3d src[]);
101 
102 
103 //averages two vectors. returns ptr to dest
104 //dest can equal either source
105 vec3d *vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1);
106 
107 vec3d *vm_vec_avg3(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2);
108 
109 //averages four vectors. returns ptr to dest
110 //dest can equal any source
111 vec3d *vm_vec_avg4(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2, const vec3d *src3);
112 
113 //scales a vector in place. returns ptr to vector
114 void vm_vec_scale(vec3d *dest, float s);
115 
116 //scales and copies a vector. returns ptr to dest
117 void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s);
118 
119 //scales a vector, adds it to another, and stores in a 3rd vector
120 //dest = src1 + k * src2
121 void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k);
122 
123 void vm_vec_scale_sub(vec3d *dest, const vec3d *src1, const vec3d *src2, float k);
124 
125 //scales a vector and adds it to another
126 //dest += k * src
127 void vm_vec_scale_add2(vec3d *dest, const vec3d *src, float k);
128 
129 //scales a vector in place, taking n/d for scale. returns ptr to vector
130 //dest *= n/d
131 void vm_vec_scale2(vec3d *dest, float n, float d);
132 
133 bool vm_vec_equal(const vec2d &self, const vec2d &other);
134 
135 bool vm_vec_equal(const vec3d &self, const vec3d &other);
136 
137 bool vm_vec_equal(const vec4 &self, const vec4 &other);
138 
139 bool vm_matrix_equal(const matrix &self, const matrix &other);
140 
141 bool vm_matrix_equal(const matrix4 &self, const matrix4 &other);
142 
143 // finds the projection of source vector along a unit vector
144 // returns the magnitude of the component
145 float vm_vec_projection_parallel (vec3d *component, const vec3d *src, const vec3d *unit_vector);
146 
147 // finds the projection of source vector onto a surface given by surface normal
148 void vm_vec_projection_onto_plane (vec3d *projection, const vec3d *src, const vec3d *normal);
149 
150 //returns magnitude of a vector
151 float vm_vec_mag(const vec3d *v);
152 
153 // returns the square of the magnitude of a vector (useful if comparing distances)
154 float vm_vec_mag_squared(const vec3d* v);
155 
156 // returns the square of the distance between two points (fast and exact)
157 float vm_vec_dist_squared(const vec3d *v0, const vec3d *v1);
158 
159 //computes the distance between two points. (does sub and mag)
160 float vm_vec_dist(const vec3d *v0, const vec3d *v1);
161 
162 //computes an approximation of the magnitude of the vector
163 //uses dist = largest + next_largest*3/8 + smallest*3/16
164 float vm_vec_mag_quick(const vec3d *v);
165 
166 //computes an approximation of the distance between two points.
167 //uses dist = largest + next_largest*3/8 + smallest*3/16
168 float vm_vec_dist_quick(const vec3d *v0, const vec3d *v1);
169 
170 
171 //normalize a vector. returns mag of source vec
172 float vm_vec_copy_normalize(vec3d *dest, const vec3d *src);
173 float vm_vec_normalize(vec3d *v);
174 
175 // This version of vector normalize checks for the null vector before normalization.
176 // If it is detected, it generates a Warning() and returns the vector 1, 0, 0.
178 
179 //normalize a vector. returns mag of source vec. uses approx mag
180 float vm_vec_copy_normalize_quick(vec3d *dest, const vec3d *src);
182 
183 //normalize a vector. returns mag of source vec. uses approx mag
184 float vm_vec_copy_normalize_quick_mag(vec3d *dest, const vec3d *src);
186 
187 //return the normalized direction vector between two points
188 //dest = normalized(end - start). Returns mag of direction vector
189 //NOTE: the order of the parameters matches the vector subtraction
190 float vm_vec_normalized_dir(vec3d *dest,const vec3d *end, const vec3d *start);
191 float vm_vec_normalized_dir_quick_mag(vec3d *dest, const vec3d *end, const vec3d *start);
192 // Returns mag of direction vector
193 float vm_vec_normalized_dir_quick(vec3d *dest, const vec3d *end, const vec3d *start);
194 
196 float vm_vec_dot(const vec3d *v0, const vec3d *v1);
197 
198 float vm_vec_dot3(float x, float y, float z, vec3d *v);
199 
200 //computes cross product of two vectors. returns ptr to dest
201 //dest CANNOT equal either source
202 vec3d *vm_vec_cross(vec3d *dest, const vec3d *src0, const vec3d *src1);
203 
204 // test if 2 vectors are parallel or not.
205 int vm_test_parallel(const vec3d *src0, const vec3d *src1);
206 
207 //computes surface normal from three points. result is normalized
208 //returns ptr to dest
209 //dest CANNOT equal either source
210 vec3d *vm_vec_normal(vec3d *dest,const vec3d *p0, const vec3d *p1, const vec3d *p2);
211 
212 //computes non-normalized surface normal from three points.
213 //returns ptr to dest
214 //dest CANNOT equal either source
215 vec3d *vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d *p2);
216 
217 //computes the delta angle between two vectors.
218 //vectors need not be normalized. if they are, call vm_vec_delta_ang_norm()
219 //the forward vector (third parameter) can be NULL, in which case the absolute
220 //value of the angle in returned. Otherwise the angle around that vector is
221 //returned.
222 float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *fvec);
223 
224 //computes the delta angle between two normalized vectors.
225 float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1,const vec3d *fvec);
226 
227 //computes a matrix from a set of three angles. returns ptr to matrix
229 
230 // Computes a matrix from a single angle.
231 // angle_index = 0,1,2 for p,b,h
232 matrix *vm_angle_2_matrix(matrix *m, float a, int angle_index);
233 
234 //computes a matrix from a forward vector and an angle
235 matrix *vm_vec_ang_2_matrix(matrix *m, const vec3d *v, float a);
236 
237 //computes a matrix from one or more vectors. The forward vector is required,
238 //with the other two being optional. If both up & right vectors are passed,
239 //the up vector is used. If only the forward vector is passed, a bank of
240 //zero is assumed
241 //returns ptr to matrix
242 matrix *vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec);
243 
244 //this version of vector_2_matrix requires that the vectors be more-or-less
245 //normalized and close to perpendicular
246 matrix *vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec = NULL, const vec3d *rvec = NULL);
247 
248 //rotates a vector through a matrix. returns ptr to dest vector
249 //dest CANNOT equal either source
250 vec3d *vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m);
251 
252 //rotates a vector through the transpose of the given matrix.
253 //returns ptr to dest vector
254 //dest CANNOT equal source
255 // This is a faster replacement for this common code sequence:
256 // vm_copy_transpose(&tempm,src_matrix);
257 // vm_vec_rotate(dst_vec,src_vect,&tempm);
258 // Replace with:
259 // vm_vec_unrotate(dst_vec,src_vect, src_matrix)
260 //
261 // THIS DOES NOT ACTUALLY TRANSPOSE THE SOURCE MATRIX!!! So if
262 // you need it transposed later on, you should use the
263 // vm_vec_transpose() / vm_vec_rotate() technique.
264 vec3d *vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m);
265 
266 //transpose a matrix in place. returns ptr to matrix
268 
269 //copy and transpose a matrix. returns ptr to matrix
270 //dest CANNOT equal source. use vm_transpose() if this is the case
271 matrix *vm_copy_transpose(matrix *dest, const matrix *src);
272 
273 //mulitply 2 matrices, fill in dest. returns ptr to dest
274 //dest CANNOT equal either source
275 matrix *vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1);
276 
277 //extract angles from a matrix
280 
281 //extract heading and pitch from a vector, assuming bank==0
283 
284 //make sure matrix is orthogonal
285 void vm_orthogonalize_matrix(matrix *m_src);
286 
287 // like vm_orthogonalize_matrix(), except that zero vectors can exist within the
288 // matrix without causing problems. Valid vectors will be created where needed.
289 void vm_fix_matrix(matrix *m);
290 
291 //Rotates the orient matrix by the angles in tangles and then
292 //makes sure that the matrix is orthogonal.
293 void vm_rotate_matrix_by_angles( matrix *orient, const angles *tangles );
294 
295 //compute the distance from a point to a plane. takes the normalized normal
296 //of the plane (ebx), a point on the plane (edi), and the point to check (esi).
297 //returns distance in eax
298 //distance is signed, so negative dist is on the back of the plane
299 float vm_dist_to_plane(const vec3d *checkp, const vec3d *norm, const vec3d *planep);
300 
301 // Given mouse movement in dx, dy, returns a 3x3 rotation matrix in RotMat.
302 // Taken from Graphics Gems III, page 51, "The Rolling Ball"
303 // Example:
304 //if ( (Mouse.dx!=0) || (Mouse.dy!=0) ) {
305 // vm_trackball( Mouse.dx, Mouse.dy, &MouseRotMat );
306 // vm_matrix_x_matrix(&tempm,&LargeView.ev_matrix,&MouseRotMat);
307 // LargeView.ev_matrix = tempm;
308 //}
309 void vm_trackball( int idx, int idy, matrix * RotMat );
310 
311 // Find the point on the line between p0 and p1 that is nearest to int_pnt.
312 // Stuff result in nearest_point.
313 // Return value indicated where on the line *nearest_point lies. Between 0.0f and 1.0f means it's
314 // in the line segment. Positive means beyond *p1, negative means before *p0. 2.0f means it's
315 // beyond *p1 by 2x.
316 float find_nearest_point_on_line(vec3d *nearest_point, const vec3d *p0, const vec3d *p1, const vec3d *int_pnt);
317 
318 float vm_vec_dot_to_point(const vec3d *dir, const vec3d *p1, const vec3d *p2);
319 
320 void compute_point_on_plane(vec3d *q, const plane *planep, const vec3d *p);
321 
322 // ----------------------------------------------------------------------------
323 // computes the point on a plane closest to a given point (which may be on the plane)
324 //
325 // inputs: new_point => point on the plane [result]
326 // point => point to compute closest plane point
327 // plane_normal => plane normal
328 // plane_point => plane point
329 void vm_project_point_onto_plane(vec3d *new_point, const vec3d *point, const vec3d *plane_normal, const vec3d *plane_point);
330 
331 
332 // Returns fairly random vector, "quick" normalized
333 void vm_vec_rand_vec_quick(vec3d *rvec);
334 
335 // Given an point "in" rotate it by "angle" around an
336 // arbritary line defined by a point on the line "line_point"
337 // and the normalized line direction, "line_dir"
338 // Returns the rotated point in "out".
339 void vm_rot_point_around_line(vec3d *out, const vec3d *in, float angle, const vec3d *line_point, const vec3d *line_dir);
340 
341 // Given two position vectors, return 0 if the same, else non-zero.
342 int vm_vec_cmp(const vec3d * a, const vec3d * b);
343 
344 // Given two orientation matrices, return 0 if the same, else non-zero.
345 int vm_matrix_cmp(const matrix * a, const matrix * b);
346 
347 // Moves angle 'h' towards 'desired_angle', taking the shortest
348 // route possible. It will move a maximum of 'step_size' radians
349 // each call. All angles in radians.
350 float vm_interp_angle( float *h, float desired_angle, float step_size, bool force_front = false );
351 
352 // calculate and return the difference (ie. delta) between two angles
353 // using same method as with vm_interp_angle().
354 float vm_delta_from_interp_angle( float current_angle, float desired_angle );
355 
356 // check a matrix for zero rows and columns
358 
359 // see if two vectors are identical
360 int vm_vec_same(const vec3d *v1, const vec3d *v2);
361 
362 // see if two matrices are identical
363 int vm_matrix_same(matrix *m1, matrix *m2);
364 
365 // Interpolate from a start matrix toward a goal matrix, minimizing time between orientations.
366 // Moves at maximum rotational acceleration toward the goal when far and then max deceleration when close.
367 // Subject to constaints on rotational velocity and angular accleleration.
368 // Returns next_orientation valid at time delta_t.
369 void vm_matrix_interpolate(const matrix *goal_orient, const matrix *start_orient, const vec3d *rotvel_in, float delta_t,
370  matrix *next_orient, vec3d *rotvel_out, const vec3d *rotvel_limit, const vec3d *acc_limit, int no_overshoot=0);
371 
372 // Interpolate from a start forward vec toward a goal forward vec, minimizing time between orientations.
373 // Moves at maximum rotational acceleration toward the goal when far and then max deceleration when close.
374 // Subject to constaints on rotational velocity and angular accleleration.
375 // Returns next forward vec valid at time delta_t.
376 void vm_forward_interpolate(const vec3d *goal_fvec, const matrix *orient, const vec3d *rotvel_in, float delta_t, float delta_bank,
377  matrix *next_orient, vec3d *rotvel_out, const vec3d *vel_limit, const vec3d *acc_limit, int no_overshoot=0);
378 
379 // Find the bounding sphere for a set of points (center and radius are output parameters)
380 void vm_find_bounding_sphere(const vec3d *pnts, int num_pnts, vec3d *center, float *radius);
381 
382 // Version of atan2() that is safe for optimized builds
383 float atan2_safe(float x, float y);
384 
385 // Translates from world coordinates to body coordinates
386 vec3d* vm_rotate_vec_to_body(vec3d *body_vec, const vec3d *world_vec, const matrix *orient);
387 
388 // Translates from body coordinates to world coordiantes
389 vec3d* vm_rotate_vec_to_world(vec3d *world_vec, const vec3d *body_vec, const matrix *orient);
390 
391 // estimate next orientation matrix as extrapolation of last and current
392 void vm_estimate_next_orientation(const matrix *last_orient, const matrix *current_orient, matrix *next_orient);
393 
394 // Return true if all elements of *vec are legal, that is, not a NAN.
395 int is_valid_vec(const vec3d *vec);
396 
397 // Return true if all elements of *m are legal, that is, not a NAN.
398 int is_valid_matrix(const matrix *m);
399 
400 // Finds the rotation matrix corresponding to a rotation of theta about axis u
401 void vm_quaternion_rotate(matrix *m, float theta, const vec3d *u);
402 
403 // Takes a rotation matrix and returns the axis and angle needed to generate it
404 void vm_matrix_to_rot_axis_and_angle(const matrix *m, float *theta, vec3d *rot_axis);
405 
406 // interpolate between 2 vectors. t goes from 0.0 to 1.0. at
407 void vm_vec_interp_constant(vec3d *out, const vec3d *v1, const vec3d *v2, float t);
408 
409 // randomly perturb a vector around a given (normalized vector) or optional orientation matrix
410 void vm_vec_random_cone(vec3d *out, const vec3d *in, float max_angle, const matrix *orient = NULL);
411 void vm_vec_random_cone(vec3d *out, const vec3d *in, float min_angle, float max_angle, const matrix *orient = NULL);
412 
413 // given a start vector, an orientation and a radius, give a point on the plane of the circle
414 // if on_edge is 1, the point is on the very edge of the circle
415 void vm_vec_random_in_circle(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge);
416 
417 // given a start vector, an orientation, and a radius, give a point in a spherical volume
418 // if on_edge is 1, the point is on the very edge of the sphere
419 void vm_vec_random_in_sphere(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge);
420 
421 // find the nearest point on the line to p. if dist is non-NULL, it is filled in
422 // returns 0 if the point is inside the line segment, -1 if "before" the line segment and 1 ir "after" the line segment
423 int vm_vec_dist_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist);
424 
425 // Goober5000
426 // Finds the distance squared to a line. Same as above, except it uses vm_vec_dist_squared, which is faster;
427 // and it doesn't check whether the nearest point is on the line segment.
428 void vm_vec_dist_squared_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist_squared);
429 
430 //SUSHI: 2D vector "box" scaling
431 void vm_vec_boxscale(vec2d *vec, float scale);
432 
433 bool vm_inverse_matrix4(const matrix4 *m, matrix4 *invOut);
434 
435 #endif
436 
437 
void vm_vec_scale2(vec3d *dest, float n, float d)
Definition: vecmat.cpp:302
float vm_vec_dot3(float x, float y, float z, vec3d *v)
float vm_vec_delta_ang(const vec3d *v0, const vec3d *v1, const vec3d *fvec)
Definition: vecmat.cpp:687
void vm_orthogonalize_matrix(matrix *m_src)
Definition: vecmat.cpp:1247
void vm_vec_scale_sub(vec3d *dest, const vec3d *src1, const vec3d *src2, float k)
Definition: vecmat.cpp:275
void vm_find_bounding_sphere(const vec3d *pnts, int num_pnts, vec3d *center, float *radius)
Definition: vecmat.cpp:2249
float vm_vec_normalize_quick(vec3d *v)
Definition: vecmat.cpp:529
vec3d * vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m)
Definition: vecmat.cpp:959
void vm_estimate_next_orientation(const matrix *last_orient, const matrix *current_orient, matrix *next_orient)
Definition: vecmat.cpp:2376
float vm_vec_mag_squared(const vec3d *v)
Definition: vecmat.cpp:339
vec3d * vm_vec_avg3(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2)
Definition: vecmat.cpp:228
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
float vm_vec_normalize(vec3d *v)
Definition: vecmat.cpp:460
int vm_matrix_cmp(const matrix *a, const matrix *b)
Definition: vecmat.cpp:1426
void vm_vec_boxscale(vec2d *vec, float scale)
Definition: vecmat.cpp:2572
vec3d * vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1)
Definition: vecmat.cpp:217
matrix * vm_angle_2_matrix(matrix *m, float a, int angle_index)
Definition: vecmat.cpp:768
void vm_rot_point_around_line(vec3d *out, const vec3d *in, float angle, const vec3d *line_point, const vec3d *line_dir)
Definition: vecmat.cpp:1395
void vm_vec_add2(vec3d *dest, const vec3d *src)
Definition: vecmat.cpp:178
float find_nearest_point_on_line(vec3d *nearest_point, const vec3d *p0, const vec3d *p1, const vec3d *int_pnt)
Definition: vecmat.cpp:1209
float vm_vec_dist_quick(const vec3d *v0, const vec3d *v1)
Definition: vecmat.cpp:417
Definition: pstypes.h:88
hull_check p0
Definition: lua.cpp:5051
float atan2_safe(float x, float y)
Definition: vecmat.cpp:68
void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k)
Definition: vecmat.cpp:266
int vm_vec_dist_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist)
Definition: vecmat.cpp:2503
enum_h * u
Definition: lua.cpp:12649
int is_valid_vec(const vec3d *vec)
Definition: vecmat.cpp:2389
float vm_vec_normalize_quick_mag(vec3d *v)
Definition: vecmat.cpp:569
void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1)
Definition: vecmat.cpp:159
vec3d * vm_vec_normal(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d *p2)
Definition: vecmat.cpp:626
float A
Definition: vecmat.h:73
hull_check orient
Definition: lua.cpp:5049
GLenum GLenum GLenum GLenum GLenum scale
Definition: Glext.h:8503
GLfloat GLfloat GLfloat v2
Definition: Glext.h:5640
void vm_vec_scale_sub2(vec3d *dest, const vec3d *src, float k)
Definition: vecmat.cpp:293
GLuint in
Definition: Glext.h:9087
int vm_check_matrix_for_zeros(const matrix *m)
Definition: vecmat.cpp:1506
float B
Definition: vecmat.h:73
vec3d * vm_vec_avg_n(vec3d *dest, int n, const vec3d src[])
Definition: vecmat.cpp:196
float vm_vec_projection_parallel(vec3d *component, const vec3d *src, const vec3d *unit_vector)
Definition: vecmat.cpp:97
GLfloat angle
Definition: Glext.h:10324
void vm_vec_scale(vec3d *dest, float s)
Definition: vecmat.cpp:248
float vm_vec_mag(const vec3d *v)
Definition: vecmat.cpp:325
float vm_vec_copy_normalize_quick(vec3d *dest, const vec3d *src)
Definition: vecmat.cpp:512
void vm_matrix_to_rot_axis_and_angle(const matrix *m, float *theta, vec3d *rot_axis)
Definition: vecmat.cpp:1612
float D
Definition: vecmat.h:73
int vm_matrix_same(matrix *m1, matrix *m2)
Definition: vecmat.cpp:1535
vec3d vmd_z_vector
Definition: vecmat.cpp:27
Definition: pstypes.h:76
void vm_trackball(int idx, int idy, matrix *RotMat)
Definition: vecmat.cpp:1151
void vm_matrix_interpolate(const matrix *goal_orient, const matrix *start_orient, const vec3d *rotvel_in, float delta_t, matrix *next_orient, vec3d *rotvel_out, const vec3d *rotvel_limit, const vec3d *acc_limit, int no_overshoot=0)
Definition: vecmat.cpp:1859
void vm_vec_random_cone(vec3d *out, const vec3d *in, float max_angle, const matrix *orient=NULL)
Definition: vecmat.cpp:2418
GLboolean GLboolean GLboolean GLboolean a
Definition: Glext.h:5781
vec3d * vm_rotate_vec_to_world(vec3d *world_vec, const vec3d *body_vec, const matrix *orient)
Definition: vecmat.cpp:2361
matrix * vm_vec_ang_2_matrix(matrix *m, const vec3d *v, float a)
Definition: vecmat.cpp:801
void vm_vec_sub2(vec3d *dest, const vec3d *src)
Definition: vecmat.cpp:187
GLfloat v0
Definition: Glext.h:5638
matrix vmd_identity_matrix
Definition: vecmat.cpp:28
matrix * vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
Definition: vecmat.cpp:850
void vm_vec_rand_vec_quick(vec3d *rvec)
Definition: vecmat.cpp:1379
GLdouble GLdouble z
Definition: Glext.h:5451
void vm_vec_dist_squared_to_line(const vec3d *p, const vec3d *l0, const vec3d *l1, vec3d *nearest, float *dist_squared)
Definition: vecmat.cpp:2543
matrix * vm_copy_transpose(matrix *dest, const matrix *src)
Definition: vecmat.cpp:984
float vm_vec_normalize_safe(vec3d *v)
Definition: vecmat.cpp:471
void vm_vec_copy_scale(vec3d *dest, const vec3d *src, float s)
Definition: vecmat.cpp:257
hull_check p1
Definition: lua.cpp:5052
GLdouble s
Definition: Glext.h:5321
float vm_vec_delta_ang_norm(const vec3d *v0, const vec3d *v1, const vec3d *fvec)
Definition: vecmat.cpp:706
void vm_vec_random_in_sphere(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge)
Definition: vecmat.cpp:2494
void vm_set_identity(matrix *m)
Definition: vecmat.cpp:150
int vm_vec_same(const vec3d *v1, const vec3d *v2)
Definition: vecmat.cpp:1526
float C
Definition: vecmat.h:73
float vm_interp_angle(float *h, float desired_angle, float step_size, bool force_front=false)
Definition: vecmat.cpp:1444
float vm_vec_mag_quick(const vec3d *v)
Definition: vecmat.cpp:371
vec3d vmd_x_vector
Definition: vecmat.cpp:25
int idx
Definition: multiui.cpp:761
GLdouble GLdouble t
Definition: Glext.h:5329
float vm_delta_from_interp_angle(float current_angle, float desired_angle)
Definition: vecmat.cpp:1487
float vm_vec_copy_normalize(vec3d *dest, const vec3d *src)
Definition: vecmat.cpp:427
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
GLclampd n
Definition: Glext.h:7286
float vm_vec_normalized_dir(vec3d *dest, const vec3d *end, const vec3d *start)
Definition: vecmat.cpp:591
angles * vm_extract_angles_matrix(angles *a, const matrix *m)
Definition: vecmat.cpp:1027
void vm_vec_scale_add2(vec3d *dest, const vec3d *src, float k)
Definition: vecmat.cpp:284
void compute_point_on_plane(vec3d *q, const plane *planep, const vec3d *p)
Definition: vecmat.cpp:1363
vec3d * vm_vec_cross(vec3d *dest, const vec3d *src0, const vec3d *src1)
Definition: vecmat.cpp:645
GLuint start
Definition: Gl.h:1502
vec3d vec
Definition: lua.cpp:2173
GLfloat GLfloat v1
Definition: Glext.h:5639
int vm_test_parallel(const vec3d *src0, const vec3d *src1)
Definition: vecmat.cpp:655
matrix * vm_transpose(matrix *m)
Definition: vecmat.cpp:971
bool vm_vec_equal(const vec2d &self, const vec2d &other)
Definition: vecmat.cpp:44
vec3d * vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m)
Definition: vecmat.cpp:933
void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1)
Definition: vecmat.cpp:168
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
struct plane plane
void vm_fix_matrix(matrix *m)
Definition: vecmat.cpp:1286
GLdouble GLdouble GLdouble GLdouble q
Definition: Glext.h:5345
float vm_dist_to_plane(const vec3d *checkp, const vec3d *norm, const vec3d *planep)
Definition: vecmat.cpp:1128
void vm_vec_interp_constant(vec3d *out, const vec3d *v1, const vec3d *v2, float t)
Definition: vecmat.cpp:2401
vec3d * vm_rotate_vec_to_body(vec3d *body_vec, const vec3d *world_vec, const matrix *orient)
Definition: vecmat.cpp:2346
vec3d * vm_vec_perp(vec3d *dest, const vec3d *p0, const vec3d *p1, const vec3d *p2)
Definition: vecmat.cpp:667
vec3d vmd_y_vector
Definition: vecmat.cpp:26
float vm_vec_normalized_dir_quick(vec3d *dest, const vec3d *end, const vec3d *start)
Definition: vecmat.cpp:604
Definition: pstypes.h:106
float vm_vec_dot(const vec3d *v0, const vec3d *v1)
Definition: vecmat.cpp:312
void vm_project_point_onto_plane(vec3d *new_point, const vec3d *point, const vec3d *plane_normal, const vec3d *plane_point)
Definition: vecmat.cpp:128
angles * vm_extract_angles_vector(angles *a, const vec3d *v)
Definition: vecmat.cpp:1114
matrix * vm_vector_2_matrix_norm(matrix *m, const vec3d *fvec, const vec3d *uvec=NULL, const vec3d *rvec=NULL)
Definition: vecmat.cpp:891
GLfloat GLfloat p
Definition: Glext.h:8373
void vm_quaternion_rotate(matrix *m, float theta, const vec3d *u)
Definition: vecmat.cpp:1548
GLenum src
Definition: Glext.h:5917
float vm_vec_dist(const vec3d *v0, const vec3d *v1)
Definition: vecmat.cpp:355
int vm_vec_cmp(const vec3d *a, const vec3d *b)
Definition: vecmat.cpp:1415
angles * vm_extract_angles_matrix_alternate(angles *a, const matrix *m)
Definition: vecmat.cpp:1064
void vm_rotate_matrix_by_angles(matrix *orient, const angles *tangles)
Definition: vecmat.cpp:1338
const GLfloat * m
Definition: Glext.h:10319
bool vm_matrix_equal(const matrix &self, const matrix &other)
Definition: vecmat.cpp:49
float vm_vec_normalized_dir_quick_mag(vec3d *dest, const vec3d *end, const vec3d *start)
Definition: vecmat.cpp:614
float vm_vec_copy_normalize_quick_mag(vec3d *dest, const vec3d *src)
Definition: vecmat.cpp:548
int is_valid_matrix(const matrix *m)
Definition: vecmat.cpp:2395
bool vm_inverse_matrix4(const matrix4 *m, matrix4 *invOut)
Attempts to invert a 4x4 matrix.
Definition: vecmat.cpp:2587
void vm_vec_random_in_circle(vec3d *out, const vec3d *in, const matrix *orient, float radius, int on_edge)
Definition: vecmat.cpp:2481
Definition: vecmat.h:72
vec3d * vm_vec_avg4(vec3d *dest, const vec3d *src0, const vec3d *src1, const vec3d *src2, const vec3d *src3)
Definition: vecmat.cpp:238
float vm_vec_dot_to_point(const vec3d *dir, const vec3d *p1, const vec3d *p2)
Definition: vecmat.cpp:1348
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
Definition: vecmat.cpp:752
vec3d vmd_zero_vector
Definition: vecmat.cpp:24
void vm_forward_interpolate(const vec3d *goal_fvec, const matrix *orient, const vec3d *rotvel_in, float delta_t, float delta_bank, matrix *next_orient, vec3d *rotvel_out, const vec3d *vel_limit, const vec3d *acc_limit, int no_overshoot=0)
Definition: vecmat.cpp:2061
void vm_vec_projection_onto_plane(vec3d *projection, const vec3d *src, const vec3d *normal)
Definition: vecmat.cpp:112
const GLdouble * v
Definition: Glext.h:5322
float vm_vec_dist_squared(const vec3d *v0, const vec3d *v1)
Definition: vecmat.cpp:344
GLuint GLuint end
Definition: Gl.h:1502
GLint y
Definition: Gl.h:1505
matrix * vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1)
Definition: vecmat.cpp:1006