UFO: Alien Invasion
Doxygen documentation generating
Loading...
Searching...
No Matches
vector.h
Go to the documentation of this file.
1
5
/*
6
Copyright (C) 1997-2001 Id Software, Inc.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17
See the GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23
*/
24
25
#pragma once
26
27
#include <cmath>
28
29
extern
const
vec2_t
vec2_origin
;
30
extern
const
vec3_t
vec3_origin
;
31
extern
const
vec4_t
vec4_origin
;
32
extern
const
vec4_t
color_white
;
33
extern
const
pos3_t
pos3_origin
;
34
35
/* Used to compare floats when rounding errors could occur */
36
#ifndef EQUAL
37
#define EQUAL(a,b) (fabsf((a)-(b))<0.0000000001f)
38
#endif
39
40
#define Vector2FromInt(x, y) { static_cast<float>(x), static_cast<float>(y) }
41
#define Vector3FromInt(x, y, z) { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }
42
44
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
45
#define VectorSubtract(a,b,dest) ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1],(dest)[2]=(a)[2]-(b)[2])
46
#define Vector2Subtract(a,b,dest) ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1])
47
#define VectorAdd(a,b,dest) ((dest)[0]=(a)[0]+(b)[0],(dest)[1]=(a)[1]+(b)[1],(dest)[2]=(a)[2]+(b)[2])
48
#define VectorMul(scalar,b,dest) ((dest)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1],(dest)[2]=(scalar)*(b)[2])
49
#define Vector2Mul(scalar,b,dest) ((c)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1])
50
#define VectorDiv(in,scalar,out) VectorScale((in),(1.0f/(scalar)),(out))
51
#define VectorCopy(src,dest) ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2])
52
#define Vector2Copy(src,dest) ((dest)[0]=(src)[0],(dest)[1]=(src)[1])
53
#define Vector4Copy(src,dest) ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2],(dest)[3]=(src)[3])
54
#define Vector2Clear(a) ((a)[0]=(a)[1]=0)
55
#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
56
#define VectorInside(vec,mins,maxs) (vec[0] >= mins[0] && vec[0] <= maxs[0] && vec[1] >= mins[1] && vec[1] <= maxs[1] && vec[2] >= mins[2] && vec[2] <= maxs[2])
57
#define Vector4Clear(a) ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0)
58
#define VectorNegate(src,dest) ((dest)[0]=-(src)[0],(dest)[1]=-(src)[1],(dest)[2]=-(src)[2])
59
#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
60
#define VectorSum(a) ((a)[0]+(a)[1]+(a)[2])
61
#define Vector2Set(v, x, y) ((v)[0]=(x), (v)[1]=(y))
62
#define Vector4Set(v, r, g, b, a) ((v)[0]=(r), (v)[1]=(g), (v)[2]=(b), (v)[3]=(a))
63
#define VectorCompare(a,b) ((a)[0]==(b)[0]?(a)[1]==(b)[1]?(a)[2]==(b)[2]?true:false:false:false)
64
#define VectorEqualEpsilon(a,b,epsilon) (EQUAL2((a)[0],(b)[0],epsilon)?EQUAL2((a)[1],(b)[1],epsilon)?EQUAL2((a)[2],(b)[2],epsilon)?true:false:false:false)
65
#define VectorEqual(a,b) (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?EQUAL((a)[2],(b)[2])?true:false:false:false)
66
#define Vector2Compare(a,b) ((a)[0]==(b)[0]?(a)[1]==(b)[1]?true:false:false)
67
#define Vector2Equal(a,b) (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?true:false:false)
68
#define VectorDistSqr(a,b) (((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])+((b)[2]-(a)[2])*((b)[2]-(a)[2]))
69
#define VectorDist(a,b) (sqrtf(((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])+((b)[2]-(a)[2])*((b)[2]-(a)[2])))
70
#define Vector2Dist(a,b) (sqrtf(((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])))
71
#define VectorLengthSqr(a) ((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2])
72
#define VectorNotEmpty(a) (!VectorEmpty((a)))
73
#define VectorEmpty(a) (VectorEqual((a), vec3_origin))
74
#define Vector2Empty(a) (Vector2Equal((a), vec2_origin))
75
#define Vector2NotEmpty(a) (!Vector2Empty((a)))
76
#define Vector4NotEmpty(a) (VectorNotEmpty(a) || !EQUAL((a)[3],0.0f))
77
#define VectorIntZero(a) ((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0)
78
#define LinearInterpolation(a, b, x, y) ((y)=(a)[1] + ((((x) - (a)[0]) * ((b)[1] - (a)[1])) / ((b)[0] - (a)[0])))
79
#define VectorScale(in,scale,out) ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale))
80
#define VectorInterpolation(p1,p2,frac,mid) ((mid)[0]=(p1)[0]+(frac)*((p2)[0]-(p1)[0]),(mid)[1]=(p1)[1]+(frac)*((p2)[1]-(p1)[1]),(mid)[2]=(p1)[2]+(frac)*((p2)[2]-(p1)[2]))
81
#define VectorAbs(a) (a[0] = fabsf(a[0]), a[1] = fabsf(a[1]), a[2] = fabsf(a[2]))
pos3_t
pos_t pos3_t[3]
Definition:
ufotypes.h:58
vec3_t
vec_t vec3_t[3]
Definition:
ufotypes.h:39
vec4_t
vec_t vec4_t[4]
Definition:
ufotypes.h:40
vec2_t
vec_t vec2_t[2]
Definition:
ufotypes.h:38
vec4_origin
const vec4_t vec4_origin
Definition:
mathlib.cpp:36
color_white
const vec4_t color_white
Definition:
r_state.cpp:1004
vec3_origin
const vec3_t vec3_origin
Definition:
mathlib.cpp:35
vec2_origin
const vec2_t vec2_origin
Definition:
mathlib.cpp:34
pos3_origin
const pos3_t pos3_origin
Definition:
mathlib.cpp:37
shared
vector.h
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.9.6