UFO: Alien Invasion
vector.h File Reference
#include <cmath>
Include dependency graph for vector.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EQUAL(a, b)   (fabsf((a)-(b))<0.0000000001f)
 
#define Vector2FromInt(x, y)   { static_cast<float>(x), static_cast<float>(y) }
 
#define Vector3FromInt(x, y, z)   { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }
 
#define DotProduct(x, y)   ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
 Returns the distance between two 3-dimensional vectors. More...
 
#define VectorSubtract(a, b, dest)   ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1],(dest)[2]=(a)[2]-(b)[2])
 
#define Vector2Subtract(a, b, dest)   ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1])
 
#define VectorAdd(a, b, dest)   ((dest)[0]=(a)[0]+(b)[0],(dest)[1]=(a)[1]+(b)[1],(dest)[2]=(a)[2]+(b)[2])
 
#define VectorMul(scalar, b, dest)   ((dest)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1],(dest)[2]=(scalar)*(b)[2])
 
#define Vector2Mul(scalar, b, dest)   ((c)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1])
 
#define VectorDiv(in, scalar, out)   VectorScale((in),(1.0f/(scalar)),(out))
 
#define VectorCopy(src, dest)   ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2])
 
#define Vector2Copy(src, dest)   ((dest)[0]=(src)[0],(dest)[1]=(src)[1])
 
#define Vector4Copy(src, dest)   ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2],(dest)[3]=(src)[3])
 
#define Vector2Clear(a)   ((a)[0]=(a)[1]=0)
 
#define VectorClear(a)   ((a)[0]=(a)[1]=(a)[2]=0)
 
#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])
 
#define Vector4Clear(a)   ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0)
 
#define VectorNegate(src, dest)   ((dest)[0]=-(src)[0],(dest)[1]=-(src)[1],(dest)[2]=-(src)[2])
 
#define VectorSet(v, x, y, z)   ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
 
#define VectorSum(a)   ((a)[0]+(a)[1]+(a)[2])
 
#define Vector2Set(v, x, y)   ((v)[0]=(x), (v)[1]=(y))
 
#define Vector4Set(v, r, g, b, a)   ((v)[0]=(r), (v)[1]=(g), (v)[2]=(b), (v)[3]=(a))
 
#define VectorCompare(a, b)   ((a)[0]==(b)[0]?(a)[1]==(b)[1]?(a)[2]==(b)[2]?true:false:false:false)
 
#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)
 
#define VectorEqual(a, b)   (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?EQUAL((a)[2],(b)[2])?true:false:false:false)
 
#define Vector2Compare(a, b)   ((a)[0]==(b)[0]?(a)[1]==(b)[1]?true:false:false)
 
#define Vector2Equal(a, b)   (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?true:false:false)
 
#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]))
 
#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])))
 
#define Vector2Dist(a, b)   (sqrtf(((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])))
 
#define VectorLengthSqr(a)   ((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2])
 
#define VectorNotEmpty(a)   (!VectorEmpty((a)))
 
#define VectorEmpty(a)   (VectorEqual((a), vec3_origin))
 
#define Vector2Empty(a)   (Vector2Equal((a), vec2_origin))
 
#define Vector2NotEmpty(a)   (!Vector2Empty((a)))
 
#define Vector4NotEmpty(a)   (VectorNotEmpty(a) || !EQUAL((a)[3],0.0f))
 
#define VectorIntZero(a)   ((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0)
 
#define LinearInterpolation(a, b, x, y)   ((y)=(a)[1] + ((((x) - (a)[0]) * ((b)[1] - (a)[1])) / ((b)[0] - (a)[0])))
 
#define VectorScale(in, scale, out)   ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale))
 
#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]))
 
#define VectorAbs(a)   (a[0] = fabsf(a[0]), a[1] = fabsf(a[1]), a[2] = fabsf(a[2]))
 

Variables

const vec2_t vec2_origin
 
const vec3_t vec3_origin
 
const vec4_t vec4_origin
 
const vec4_t color_white
 
const pos3_t pos3_origin
 

Macro Definition Documentation

◆ DotProduct

#define DotProduct (   x,
 
)    ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])

Returns the distance between two 3-dimensional vectors.

Definition at line 44 of file vector.h.

◆ EQUAL

#define EQUAL (   a,
 
)    (fabsf((a)-(b))<0.0000000001f)

Definition at line 37 of file vector.h.

◆ LinearInterpolation

#define LinearInterpolation (   a,
  b,
  x,
 
)    ((y)=(a)[1] + ((((x) - (a)[0]) * ((b)[1] - (a)[1])) / ((b)[0] - (a)[0])))

Definition at line 78 of file vector.h.

◆ Vector2Clear

#define Vector2Clear (   a)    ((a)[0]=(a)[1]=0)

Definition at line 54 of file vector.h.

◆ Vector2Compare

#define Vector2Compare (   a,
 
)    ((a)[0]==(b)[0]?(a)[1]==(b)[1]?true:false:false)

Definition at line 66 of file vector.h.

◆ Vector2Copy

#define Vector2Copy (   src,
  dest 
)    ((dest)[0]=(src)[0],(dest)[1]=(src)[1])

Definition at line 52 of file vector.h.

◆ Vector2Dist

#define Vector2Dist (   a,
 
)    (sqrtf(((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])))

Definition at line 70 of file vector.h.

◆ Vector2Empty

#define Vector2Empty (   a)    (Vector2Equal((a), vec2_origin))

Definition at line 74 of file vector.h.

◆ Vector2Equal

#define Vector2Equal (   a,
 
)    (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?true:false:false)

Definition at line 67 of file vector.h.

◆ Vector2FromInt

#define Vector2FromInt (   x,
 
)    { static_cast<float>(x), static_cast<float>(y) }

Definition at line 40 of file vector.h.

◆ Vector2Mul

#define Vector2Mul (   scalar,
  b,
  dest 
)    ((c)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1])

Definition at line 49 of file vector.h.

◆ Vector2NotEmpty

#define Vector2NotEmpty (   a)    (!Vector2Empty((a)))

Definition at line 75 of file vector.h.

◆ Vector2Set

#define Vector2Set (   v,
  x,
 
)    ((v)[0]=(x), (v)[1]=(y))

Definition at line 61 of file vector.h.

◆ Vector2Subtract

#define Vector2Subtract (   a,
  b,
  dest 
)    ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1])

Definition at line 46 of file vector.h.

◆ Vector3FromInt

#define Vector3FromInt (   x,
  y,
 
)    { static_cast<float>(x), static_cast<float>(y), static_cast<float>(z) }

Definition at line 41 of file vector.h.

◆ Vector4Clear

#define Vector4Clear (   a)    ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0)

Definition at line 57 of file vector.h.

◆ Vector4Copy

#define Vector4Copy (   src,
  dest 
)    ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2],(dest)[3]=(src)[3])

Definition at line 53 of file vector.h.

◆ Vector4NotEmpty

#define Vector4NotEmpty (   a)    (VectorNotEmpty(a) || !EQUAL((a)[3],0.0f))

Definition at line 76 of file vector.h.

◆ Vector4Set

#define Vector4Set (   v,
  r,
  g,
  b,
 
)    ((v)[0]=(r), (v)[1]=(g), (v)[2]=(b), (v)[3]=(a))

Definition at line 62 of file vector.h.

◆ VectorAbs

#define VectorAbs (   a)    (a[0] = fabsf(a[0]), a[1] = fabsf(a[1]), a[2] = fabsf(a[2]))

Definition at line 81 of file vector.h.

◆ VectorAdd

#define VectorAdd (   a,
  b,
  dest 
)    ((dest)[0]=(a)[0]+(b)[0],(dest)[1]=(a)[1]+(b)[1],(dest)[2]=(a)[2]+(b)[2])

Definition at line 47 of file vector.h.

◆ VectorClear

#define VectorClear (   a)    ((a)[0]=(a)[1]=(a)[2]=0)

Definition at line 55 of file vector.h.

◆ VectorCompare

#define VectorCompare (   a,
 
)    ((a)[0]==(b)[0]?(a)[1]==(b)[1]?(a)[2]==(b)[2]?true:false:false:false)

Definition at line 63 of file vector.h.

◆ VectorCopy

#define VectorCopy (   src,
  dest 
)    ((dest)[0]=(src)[0],(dest)[1]=(src)[1],(dest)[2]=(src)[2])

Definition at line 51 of file vector.h.

◆ VectorDist

#define VectorDist (   a,
 
)    (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])))

Definition at line 69 of file vector.h.

◆ VectorDistSqr

#define VectorDistSqr (   a,
 
)    (((b)[0]-(a)[0])*((b)[0]-(a)[0])+((b)[1]-(a)[1])*((b)[1]-(a)[1])+((b)[2]-(a)[2])*((b)[2]-(a)[2]))

Definition at line 68 of file vector.h.

◆ VectorDiv

#define VectorDiv (   in,
  scalar,
  out 
)    VectorScale((in),(1.0f/(scalar)),(out))

Definition at line 50 of file vector.h.

◆ VectorEmpty

#define VectorEmpty (   a)    (VectorEqual((a), vec3_origin))

Definition at line 73 of file vector.h.

◆ VectorEqual

#define VectorEqual (   a,
 
)    (EQUAL((a)[0],(b)[0])?EQUAL((a)[1],(b)[1])?EQUAL((a)[2],(b)[2])?true:false:false:false)

Definition at line 65 of file vector.h.

◆ VectorEqualEpsilon

#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)

Definition at line 64 of file vector.h.

◆ VectorInside

#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])

Definition at line 56 of file vector.h.

◆ VectorInterpolation

#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]))

Definition at line 80 of file vector.h.

◆ VectorIntZero

#define VectorIntZero (   a)    ((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0)

Definition at line 77 of file vector.h.

◆ VectorLengthSqr

#define VectorLengthSqr (   a)    ((a)[0]*(a)[0]+(a)[1]*(a)[1]+(a)[2]*(a)[2])

Definition at line 71 of file vector.h.

◆ VectorMul

#define VectorMul (   scalar,
  b,
  dest 
)    ((dest)[0]=(scalar)*(b)[0],(dest)[1]=(scalar)*(b)[1],(dest)[2]=(scalar)*(b)[2])

Definition at line 48 of file vector.h.

◆ VectorNegate

#define VectorNegate (   src,
  dest 
)    ((dest)[0]=-(src)[0],(dest)[1]=-(src)[1],(dest)[2]=-(src)[2])

Definition at line 58 of file vector.h.

◆ VectorNotEmpty

#define VectorNotEmpty (   a)    (!VectorEmpty((a)))

Definition at line 72 of file vector.h.

◆ VectorScale

#define VectorScale (   in,
  scale,
  out 
)    ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale))

Definition at line 79 of file vector.h.

◆ VectorSet

#define VectorSet (   v,
  x,
  y,
 
)    ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))

Definition at line 59 of file vector.h.

◆ VectorSubtract

#define VectorSubtract (   a,
  b,
  dest 
)    ((dest)[0]=(a)[0]-(b)[0],(dest)[1]=(a)[1]-(b)[1],(dest)[2]=(a)[2]-(b)[2])

Definition at line 45 of file vector.h.

◆ VectorSum

#define VectorSum (   a)    ((a)[0]+(a)[1]+(a)[2])

Definition at line 60 of file vector.h.

Variable Documentation

◆ color_white

const vec4_t color_white
extern

Definition at line 1004 of file r_state.cpp.

Referenced by R_Color().

◆ pos3_origin

const pos3_t pos3_origin
extern

Definition at line 37 of file mathlib.cpp.

Referenced by AiAreaSearch::AiAreaSearch().

◆ vec2_origin

const vec2_t vec2_origin
extern

Definition at line 34 of file mathlib.cpp.

Referenced by GEO_GetGeoscapeAngle().

◆ vec3_origin

◆ vec4_origin

const vec4_t vec4_origin
extern

Definition at line 36 of file mathlib.cpp.

Referenced by R_DrawModelDirect(), and R_DrawModelParticle().