comments/formatting
This commit is contained in:
parent
4465861130
commit
84e8d64941
|
@ -1,3 +1,7 @@
|
|||
2004-05-18 Bradley Bell <btb@icculus.org>
|
||||
|
||||
* include/vecmat.h: comments/formatting
|
||||
|
||||
2004-05-18 Martin Schaffner <maschaffner@gmx.ch>
|
||||
|
||||
* include/d.bat, include/lst.bat, include/m.bat, include/test.c,
|
||||
|
|
196
include/vecmat.h
196
include/vecmat.h
|
@ -1,4 +1,4 @@
|
|||
/* $ Id: $ */
|
||||
/* $Id: vecmat.h,v 1.5 2004-05-19 01:47:24 btb Exp $ */
|
||||
/*
|
||||
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
||||
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
||||
|
@ -8,9 +8,9 @@
|
|||
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
||||
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
||||
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
||||
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||
*/
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Header file for vector/matrix library
|
||||
|
@ -25,128 +25,128 @@
|
|||
* Revision 1.37 1995/02/22 13:23:22 john
|
||||
* Added the vms_vector_array structure, to access a vms_vector
|
||||
* with an array.
|
||||
*
|
||||
*
|
||||
* Revision 1.36 1995/02/22 12:34:33 john
|
||||
* Took out anonymous unions.
|
||||
*
|
||||
*
|
||||
* Revision 1.35 1994/12/13 14:44:20 matt
|
||||
* Added vm_vector_2_matrix_norm()
|
||||
*
|
||||
*
|
||||
* Revision 1.34 1994/09/11 19:22:55 matt
|
||||
* Added vm_vec_normalized_dir_quick()
|
||||
*
|
||||
*
|
||||
* Revision 1.33 1994/08/04 19:45:38 matt
|
||||
* Added option to make a bunch of functions (add, sub, dotprod) inline
|
||||
*
|
||||
*
|
||||
* Revision 1.32 1994/07/19 18:52:36 matt
|
||||
* Added vm_vec_normalize_quick() and vm_vec_copy_normalize_quick()
|
||||
*
|
||||
*
|
||||
* Revision 1.31 1994/06/16 18:24:30 matt
|
||||
* Added vm_vec_mag_quick()
|
||||
*
|
||||
*
|
||||
* Revision 1.30 1994/06/10 23:19:00 matt
|
||||
* New register usage for vm_vec_ang_2_matrix()
|
||||
*
|
||||
*
|
||||
* Revision 1.29 1994/06/01 17:32:06 matt
|
||||
* Fixed modify list for vm_vec_normalized_dir()
|
||||
*
|
||||
*
|
||||
* Revision 1.28 1994/05/19 12:07:20 matt
|
||||
* Fixed globals and macros and added a constant
|
||||
*
|
||||
*
|
||||
* Revision 1.27 1994/05/19 09:19:15 matt
|
||||
* Made vm_vec_normalized_dir() return mag of vector
|
||||
*
|
||||
*
|
||||
* Revision 1.26 1994/05/18 22:28:57 matt
|
||||
* Added function vm_vec_normalized_dir()
|
||||
* Added C macros IS_ZERO_VEC(), vm_vec_zero(), and vm_set_identity()
|
||||
* Added C global static vars vmd_zero_vector & vmd_identity_matrix
|
||||
*
|
||||
*
|
||||
* Revision 1.25 1994/05/18 21:45:06 matt
|
||||
* Added functions:
|
||||
* vm_extract_angles_vector()
|
||||
* vm_extract_angles_vector_normalized()
|
||||
* vm_vec_copy_normalize()
|
||||
*
|
||||
*
|
||||
* Revision 1.24 1994/05/13 12:42:16 matt
|
||||
* Added new function, vm_vec_dist_quick(), which does an approximation.
|
||||
*
|
||||
*
|
||||
* Revision 1.23 1994/03/30 13:37:34 matt
|
||||
* Added prototype for vm_vec_scale_add(), and fixed typos
|
||||
*
|
||||
*
|
||||
* Revision 1.22 1994/03/30 13:29:42 matt
|
||||
* Header for vm_vec_scale_add2()
|
||||
*
|
||||
*
|
||||
* Revision 1.21 1994/01/31 19:45:13 matt
|
||||
* Added function vm_extract_angles_matrix()
|
||||
*
|
||||
*
|
||||
* Revision 1.20 1993/12/21 19:46:14 matt
|
||||
* Added function vm_dist_to_plane()
|
||||
*
|
||||
*
|
||||
* Revision 1.19 1993/12/13 17:26:41 matt
|
||||
* Added vm_vec_dist()
|
||||
*
|
||||
*
|
||||
* Revision 1.18 1993/12/02 12:45:11 matt
|
||||
* New functions: vm_vec_copy_scale(), vm_vec_scale2()
|
||||
* Aliases: vm_transpose(), vm_vec_dot(), vm_vec_cross(), vm_copy_transpose()
|
||||
*
|
||||
*
|
||||
* Revision 1.17 1993/10/29 22:38:36 matt
|
||||
* Changed matrix order, making direction vectors the rows
|
||||
*
|
||||
*
|
||||
* Revision 1.16 1993/10/25 11:49:57 matt
|
||||
* Made vm_vec_delta_ang() take optional forward vector to return signed delta
|
||||
*
|
||||
*
|
||||
* Revision 1.15 1993/10/20 01:10:05 matt
|
||||
* Added vm_vec_delta_ang(), vm_vec_delta_ang_norm(), and vm_vec_ang_2_matrix()
|
||||
*
|
||||
*
|
||||
* Revision 1.14 1993/10/17 17:02:52 matt
|
||||
* vm_vector_2_matrix() now takes optional right vector
|
||||
*
|
||||
*
|
||||
* Revision 1.13 1993/10/12 19:31:39 matt
|
||||
* Added IDENTITY_MATRIX constant
|
||||
*
|
||||
*
|
||||
* Revision 1.12 1993/10/08 18:10:16 matt
|
||||
* Changed vm_vec_make() and vm_angvec_make() to be inline assembly
|
||||
* Changed vm_vec_make() and vm_angvec_make() to be inline assembly
|
||||
* functions, to get rid of compiler warnings. Did not change vm_mat_make(),
|
||||
* which could still get warnings if the return value is unused.
|
||||
*
|
||||
*
|
||||
* Revision 1.11 1993/09/29 12:10:07 matt
|
||||
* Changed modified regs in pragmas to include return register
|
||||
*
|
||||
*
|
||||
* Revision 1.10 1993/09/28 12:15:41 matt
|
||||
* Added func vm_vector_2_matrix()
|
||||
*
|
||||
*
|
||||
* Revision 1.9 1993/09/24 21:18:38 matt
|
||||
* Added vm_vec_avg(), vm_vec_avg4(), and vm_angvec_make().
|
||||
* Documented which functions could have dest==source
|
||||
*
|
||||
*
|
||||
* Revision 1.8 1993/09/20 14:56:11 matt
|
||||
* Added new function, vm_vec_perp()
|
||||
*
|
||||
*
|
||||
* Revision 1.7 1993/09/20 14:27:42 mike
|
||||
* unfix last fix which introduced a bug
|
||||
*
|
||||
*
|
||||
* Revision 1.6 1993/09/20 10:11:53 mike
|
||||
* no changes
|
||||
*
|
||||
*
|
||||
* Revision 1.5 1993/09/20 09:58:58 mike
|
||||
* Re-fix vm_vec_make
|
||||
*
|
||||
*
|
||||
* Revision 1.4 1993/09/20 09:41:21 mike
|
||||
* Correct vm_vec_make and vm_mat_make macros to return the destination
|
||||
* as the value of the macro.
|
||||
*
|
||||
*
|
||||
* Revision 1.3 1993/09/17 11:23:47 matt
|
||||
* Added row access (via xrow,yrow,zrow) to vms_matrix
|
||||
* Added macro vm_mat_make(), like vm_vec_make()
|
||||
*
|
||||
*
|
||||
* Revision 1.2 1993/09/17 11:10:32 matt
|
||||
* Added vm_vec_add2() and vm_vec_sub2(), which take 2 args (dest==src0)
|
||||
*
|
||||
*
|
||||
* Revision 1.1 1993/09/16 20:10:01 matt
|
||||
* Initial revision
|
||||
*
|
||||
*
|
||||
*/
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VECMAT_H
|
||||
#define _VECMAT_H
|
||||
|
@ -157,52 +157,42 @@
|
|||
|
||||
//The basic fixed-point vector. Access elements by name or position
|
||||
typedef struct vms_vector
|
||||
{
|
||||
|
||||
fix x, y, z;
|
||||
|
||||
}
|
||||
{
|
||||
fix x, y, z;
|
||||
}
|
||||
__pack__ vms_vector;
|
||||
|
||||
|
||||
typedef struct vms_vector_array
|
||||
{
|
||||
|
||||
fix xyz[3];
|
||||
|
||||
}
|
||||
{
|
||||
fix xyz[3];
|
||||
}
|
||||
__pack__ vms_vector_array;
|
||||
|
||||
|
||||
//Short vector, used for pre-rotation points.
|
||||
//Short vector, used for pre-rotation points.
|
||||
//Access elements by name or position
|
||||
typedef struct vms_svec
|
||||
{
|
||||
|
||||
short sv_x, sv_y, sv_z;
|
||||
|
||||
}
|
||||
{
|
||||
short sv_x, sv_y, sv_z;
|
||||
}
|
||||
__pack__ vms_svec;
|
||||
|
||||
|
||||
//Angle vector. Used to store orientations
|
||||
typedef struct vms_angvec
|
||||
{
|
||||
|
||||
fixang p, b, h;
|
||||
|
||||
}
|
||||
{
|
||||
fixang p, b, h;
|
||||
}
|
||||
__pack__ vms_angvec;
|
||||
|
||||
|
||||
//A 3x3 rotation matrix. Sorry about the numbering starting with one.
|
||||
//Ordering is across then down, so <m1,m2,m3> is the first row
|
||||
typedef struct vms_matrix
|
||||
{
|
||||
|
||||
vms_vector rvec, uvec, fvec;
|
||||
|
||||
}
|
||||
{
|
||||
vms_vector rvec, uvec, fvec;
|
||||
}
|
||||
__pack__ vms_matrix;
|
||||
|
||||
|
||||
|
@ -211,7 +201,7 @@ __pack__ vms_matrix;
|
|||
//macro to check if vector is zero
|
||||
#define IS_VEC_NULL(v) (v->x == 0 && v->y == 0 && v->z == 0)
|
||||
|
||||
//macro to set a vector to zero. we could do this with an in-line assembly
|
||||
//macro to set a vector to zero. we could do this with an in-line assembly
|
||||
//macro, but it's probably better to let the compiler optimize it.
|
||||
//Note: NO RETURN VALUE
|
||||
#define vm_vec_zero(v) (v)->x=(v)->y=(v)->z=0
|
||||
|
@ -224,8 +214,8 @@ __pack__ vms_matrix;
|
|||
#ifdef __unix__
|
||||
static inline void vm_set_identity(vms_matrix *m)
|
||||
{
|
||||
m->rvec.x = m->uvec.y = m->fvec.z = f1_0;
|
||||
m->rvec.y = m->rvec.z = m->uvec.x = m->uvec.z = m->fvec.x = m->fvec.y = 0;
|
||||
m->rvec.x = m->uvec.y = m->fvec.z = f1_0;
|
||||
m->rvec.y = m->rvec.z = m->uvec.x = m->uvec.z = m->fvec.x = m->fvec.y = 0;
|
||||
}
|
||||
#else
|
||||
#define vm_set_identity(m) do {m->rvec.x = m->uvec.y = m->fvec.z = f1_0; \
|
||||
|
@ -291,18 +281,17 @@ extern vms_matrix vmd_identity_matrix;
|
|||
do { (m)->m1=(_m1); (m)->m2=(_m2); (m)->m3=(_m3); \
|
||||
(m)->m4=(_m4); (m)->m5=(_m5); (m)->m6=(_m6); \
|
||||
(m)->m7=(_m7); (m)->m8=(_m8); (m)->m9=(_m9);} while (0)
|
||||
*/
|
||||
*/
|
||||
|
||||
#if 0 //kill this, since bogus with new matrix ordering
|
||||
#if 0 //kill this, since bogus with new matrix ordering
|
||||
|
||||
//macro to fill in elements of a matrix, also for Mike
|
||||
#define vm_mat_make(m,_m1,_m2,_m3,_m4,_m5,_m6,_m7,_m8,_m9) \
|
||||
(((m)->m1 = (_m1), (m)->m2 = (_m2), (m)->m3 = (_m3), \
|
||||
(m)->m4 = (_m4), (m)->m5 = (_m5), (m)->m6 = (_m6), \
|
||||
(m)->m7 = (_m7), (m)->m8 = (_m8), (m)->m9 = (_m9)), (m))
|
||||
(m)->m7 = (_m7), (m)->m8 = (_m8), (m)->m9 = (_m9)), (m))
|
||||
|
||||
#endif /*
|
||||
*/
|
||||
#endif /* 0 */
|
||||
|
||||
////fills in fields of an angle vector
|
||||
//#define vm_angvec_make(v,_p,_b,_h) (((v)->p=(_p), (v)->b=(_b), (v)->h=(_h)), (v))
|
||||
|
@ -334,10 +323,9 @@ vms_vector * vm_vec_add2 (vms_vector * dest, vms_vector * src);
|
|||
vms_vector * vm_vec_sub2 (vms_vector * dest, vms_vector * src);
|
||||
|
||||
|
||||
#else /*
|
||||
*/
|
||||
#else /* INLINE */
|
||||
|
||||
#define vm_vec_add(dest,src0,src1) do { \
|
||||
#define vm_vec_add(dest,src0,src1) do { \
|
||||
(dest)->x = (src0)->x + (src1)->x;
|
||||
\
|
||||
(dest)->y = (src0)->y + (src1)->y;
|
||||
|
@ -348,7 +336,7 @@ vms_vector * vm_vec_sub2 (vms_vector * dest, vms_vector * src);
|
|||
while (0);
|
||||
|
||||
|
||||
#define vm_vec_sub(dest,src0,src1) do { \
|
||||
#define vm_vec_sub(dest,src0,src1) do { \
|
||||
(dest)->x = (src0)->x - (src1)->x;
|
||||
\
|
||||
(dest)->y = (src0)->y - (src1)->y;
|
||||
|
@ -359,7 +347,7 @@ while (0);
|
|||
while (0);
|
||||
|
||||
|
||||
#define vm_vec_add2(dest,src) do { \
|
||||
#define vm_vec_add2(dest,src) do { \
|
||||
(dest)->x += (src)->x;
|
||||
\
|
||||
(dest)->y += (src)->y;
|
||||
|
@ -370,7 +358,7 @@ while (0);
|
|||
while (0);
|
||||
|
||||
|
||||
#define vm_vec_sub2(dest,src) do { \
|
||||
#define vm_vec_sub2(dest,src) do { \
|
||||
(dest)->x -= (src)->x;
|
||||
\
|
||||
(dest)->y -= (src)->y;
|
||||
|
@ -381,8 +369,7 @@ while (0);
|
|||
while (0);
|
||||
|
||||
|
||||
#endif /*
|
||||
*/
|
||||
#endif /* INLINE */
|
||||
|
||||
//averages two vectors. returns ptr to dest
|
||||
//dest can equal either source
|
||||
|
@ -464,26 +451,25 @@ fix vm_vec_dotprod (vms_vector * v0, vms_vector * v1);
|
|||
#ifdef INLINE
|
||||
#ifdef __WATCOMC__
|
||||
#pragma aux vm_vec_dotprod parm [esi] [edi] value [eax] modify exact [eax ebx ecx edx] = \
|
||||
"mov eax,[esi]" \
|
||||
"imul dword ptr [edi]" \
|
||||
"mov ebx,eax" \
|
||||
"mov ecx,edx" \
|
||||
"mov eax,[esi]" \
|
||||
"imul dword ptr [edi]" \
|
||||
"mov ebx,eax" \
|
||||
"mov ecx,edx" \
|
||||
\
|
||||
"mov eax,4[esi]" \
|
||||
"imul dword ptr 4[edi]" \
|
||||
"add ebx,eax" \
|
||||
"adc ecx,edx" \
|
||||
"mov eax,4[esi]" \
|
||||
"imul dword ptr 4[edi]" \
|
||||
"add ebx,eax" \
|
||||
"adc ecx,edx" \
|
||||
\
|
||||
"mov eax,8[esi]" \
|
||||
"imul dword ptr 8[edi]" \
|
||||
"add eax,ebx" \
|
||||
"adc edx,ecx" \
|
||||
"mov eax,8[esi]" \
|
||||
"imul dword ptr 8[edi]" \
|
||||
"add eax,ebx" \
|
||||
"adc edx,ecx" \
|
||||
\
|
||||
"shrd eax,edx,16";
|
||||
"shrd eax,edx,16";
|
||||
|
||||
#endif
|
||||
#endif /*
|
||||
*/
|
||||
#endif /* INLINE */
|
||||
|
||||
//computes cross product of two vectors. returns ptr to dest
|
||||
//dest CANNOT equal either source
|
||||
|
@ -497,13 +483,13 @@ vms_vector * vm_vec_crossprod (vms_vector * dest, vms_vector * src0, vms_vector
|
|||
vms_vector * vm_vec_normal (vms_vector * dest, vms_vector * p0, vms_vector * p1, vms_vector * p2);
|
||||
|
||||
|
||||
//computes non-normalized surface normal from three points.
|
||||
//computes non-normalized surface normal from three points.
|
||||
//returns ptr to dest
|
||||
//dest CANNOT equal either source
|
||||
vms_vector * vm_vec_perp (vms_vector * dest, vms_vector * p0, vms_vector * p1, vms_vector * p2);
|
||||
|
||||
|
||||
//computes the delta angle between two vectors.
|
||||
//computes the delta angle between two vectors.
|
||||
//vectors need not be normalized. if they are, call vm_vec_delta_ang_norm()
|
||||
//the forward vector (third parameter) can be NULL, in which case the absolute
|
||||
//value of the angle in returned. Otherwise the angle around that vector is
|
||||
|
@ -511,7 +497,7 @@ vms_vector * vm_vec_perp (vms_vector * dest, vms_vector * p0, vms_vector * p1, v
|
|||
fixang vm_vec_delta_ang (vms_vector * v0, vms_vector * v1, vms_vector * fvec);
|
||||
|
||||
|
||||
//computes the delta angle between two normalized vectors.
|
||||
//computes the delta angle between two normalized vectors.
|
||||
fixang vm_vec_delta_ang_norm (vms_vector * v0, vms_vector * v1, vms_vector * fvec);
|
||||
|
||||
|
||||
|
@ -557,7 +543,7 @@ vms_matrix * vm_copy_transpose_matrix (vms_matrix * dest, vms_matrix * src);
|
|||
vms_matrix * vm_matrix_x_matrix (vms_matrix * dest, vms_matrix * src0, vms_matrix * src1);
|
||||
|
||||
|
||||
//extract angles from a matrix
|
||||
//extract angles from a matrix
|
||||
vms_angvec * vm_extract_angles_matrix (vms_angvec * a, vms_matrix * m);
|
||||
|
||||
|
||||
|
@ -574,6 +560,4 @@ fix vm_dist_to_plane (vms_vector * checkp, vms_vector * norm, vms_vector * plane
|
|||
|
||||
//fills in fields of an angle vector
|
||||
#define vm_angvec_make(v,_p,_b,_h) (((v)->p=(_p), (v)->b=(_b), (v)->h=(_h)), (v))
|
||||
#endif /*
|
||||
*/
|
||||
|
||||
#endif /* !_VECMAT_H */
|
||||
|
|
Loading…
Reference in a new issue