|
Odamex
Setting the Standard in Multiplayer Doom
|
00001 // Emacs style mode select -*- C++ -*- 00002 //----------------------------------------------------------------------------- 00003 // 00004 // $Id: vectors.h 1788 2010-08-24 04:42:57Z russellrice $ 00005 // 00006 // Copyright (C) 1997-2000 by id Software Inc. 00007 // Copyright (C) 1998-2006 by Randy Heit (ZDoom). 00008 // Copyright (C) 2006-2010 by The Odamex Team. 00009 // 00010 // This program is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU General Public License 00012 // as published by the Free Software Foundation; either version 2 00013 // of the License, or (at your option) any later version. 00014 // 00015 // This program is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // DESCRIPTION: 00021 // Vector math routines which I took from Quake2's source since they 00022 // make more sense than the way Doom does things. :-) 00023 // 00024 //----------------------------------------------------------------------------- 00025 00026 00027 #ifndef __VECTORS_H__ 00028 #define __VECTORS_H__ 00029 00030 00031 #include "tables.h" 00032 00033 typedef float vec_t; 00034 typedef vec_t vec3_t[3]; 00035 00036 #define FIXED2FLOAT(f) ((float)(f) / (float)FRACUNIT) 00037 #define FLOAT2FIXED(f) (fixed_t)((f) * (float)FRACUNIT) 00038 00039 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) 00040 #define VectorSubtract(a,b,c) (c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2]) 00041 #define VectorAdd(a,b,c) (c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2]) 00042 #define VectorCopy(a,b) (b[0]=a[0],b[1]=a[1],b[2]=a[2]) 00043 #define VectorClear(a) (a[0]=a[1]=a[2]=0) 00044 #define VectorNegate(a,b) (b[0]=-a[0],b[1]=-a[1],b[2]=-a[2]) 00045 #define VectorSet(v, x, y, z) (v[0]=(x), v[1]=(y), v[2]=(z)) 00046 #define VectorFixedSet(v,x,y,z) (v[0]=FIXED2FLOAT(x), v[1]=FIXED2FLOAT(y), v[2]=FIXED2FLOAT(z)) 00047 #define VectorInverse(v) (v[0]=-v[0],v[1]=-v[1],v[2]=-v[2]) 00048 00049 class AActor; 00050 00051 void VectorPosition (const class AActor *thing, vec3_t out); 00052 void FixedAngleToVector (angle_t an, fixed_t pitch, vec3_t v); 00053 vec_t VectorLength (const vec3_t v); 00054 void VectorMA (const vec3_t a, float scale, const vec3_t b, vec3_t out); 00055 void VectorScale (const vec3_t v, float scale, vec3_t out); 00056 void VectorScale2 (vec3_t v, float scale); 00057 int VectorCompare (const vec3_t v1, const vec3_t v2); 00058 vec_t VectorNormalize (vec3_t v); 00059 vec_t VectorNormalize2 (const vec3_t v, vec3_t out); 00060 void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross); 00061 void ProjectPointOnPlane (vec3_t dst, const vec3_t p, const vec3_t normal); 00062 void PerpendicularVector (vec3_t dst, const vec3_t src); 00063 void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees); 00064 void R_ConcatRotations (const float in1[3][3], const float in2[3][3], float out[3][3]); 00065 00066 #endif //__VECTORS_H__ 00067