#include "ufotypes.h"
Go to the source code of this file.
Defines | |
#define | EQUAL_EPSILON 0.001 |
#define | Q_ftol(f) (long) (f) |
#define | torad (M_PI/180.0f) |
#define | todeg (180.0f/M_PI) |
#define | PITCH 0 |
#define | YAW 1 |
#define | ROLL 2 |
#define | SIN_ALPHA 0.39875 |
#define | COS_ALPHA 0.91706 |
#define | HIGH_LAT +1.0 |
#define | LOW_LAT -1.0 |
#define | CENTER_LAT 0.0 |
#define | SIZE_LAT 2.0 |
#define | DIRECTIONS 8 |
Number of angles from a position (2-dimensional). | |
#define | BASE_DIRECTIONS 4 |
Number of direct connected fields for a position. | |
#define | PATHFINDING_DIRECTIONS 40 |
#define | CORE_DIRECTIONS 8 |
#define | FLYING_DIRECTIONS 16 |
#define | VecToPos(v, p) |
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative value and divide by the size of a grid unit field. | |
#define | PosToVec(p, v) |
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value and multiply with the grid unit size to get back the vector coordinates - now go into the middle of the grid field by adding the half of the grid unit size to this value. | |
#define | DotProduct(x, y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) |
Returns the distance between two 3-dimensional vectors. | |
#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 | 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]?1:0:0:0) |
#define | VectorEqual(a, b) (equal(a[0],b[0])?equal(a[1],b[1])?equal(a[2],b[2])?1:0:0:0) |
#define | Vector2Compare(a, b) (a[0]==b[0]?a[1]==b[1]?1:0:0) |
#define | Vector2Equal(a, b) (equal(a[0],b[0])?equal(a[1],b[1])?1:0:0) |
#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) (sqrt((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) (sqrt((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) (a[0]||a[1]||a[2]) |
#define | Vector4NotEmpty(a) (a[0]||a[1]||a[2]||a[3]) |
#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 | DV_Z_BIT_SHIFT 3 |
#define | DV_Z_BIT_MASK ((1 << DV_Z_BIT_SHIFT) - 1) |
#define | makeDV(dir, z) ((dir << DV_Z_BIT_SHIFT) | (z & DV_Z_BIT_MASK)) |
#define | NewDVZ(dv, z) ((dv & (~DV_Z_BIT_MASK)) | (z & DV_Z_BIT_MASK)) |
#define | getDVdir(dv) (dv >> DV_Z_BIT_SHIFT) |
#define | getDVz(dv) (dv & DV_Z_BIT_MASK) |
#define | PosAddDV(p, crouch, dv) (p[0]+=dvecs[getDVdir(dv)][0], p[1]+=dvecs[getDVdir(dv)][1], p[2]=getDVz(dv), crouch+=dvecs[getDVdir(dv)][3]) |
#define | PosSubDV(p, crouch, dv) (p[0]-=dvecs[getDVdir(dv)][0], p[1]-=dvecs[getDVdir(dv)][1], p[2]=getDVz(dv), crouch-=dvecs[getDVdir(dv)][3]) |
#define | AngleToDV(x) (AngleToDir(x) << DV_Z_BIT_SHIFT) |
Typedefs | |
typedef float | vec_t |
typedef vec_t | vec2_t [2] |
typedef vec_t | vec3_t [3] |
typedef vec_t | vec4_t [4] |
typedef vec_t | vec5_t [5] |
typedef byte | pos_t |
typedef pos_t | pos3_t [3] |
typedef pos_t | pos4_t [4] |
Functions | |
qboolean | Q_IsPowerOfTwo (int i) |
Checks whether i is power of two value. | |
int | AngleToDir (int angle) |
Returns the indice of array directionAngles[DIRECTIONS] whose value is the closest to angle. | |
void | VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector) |
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb). | |
void | VectorClampMA (vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc) |
void | VectorMix (const vec3_t v1, const vec3_t v2, const float mix, vec3_t out) |
Calculate a position on v1 v2 line. | |
void | MatrixMultiply (const vec3_t a[3], const vec3_t b[3], vec3_t c[3]) |
Multiply 3*3 matrix by 3*3 matrix. | |
void | GLMatrixAssemble (const vec3_t origin, const vec3_t angles, float *matrix) |
Builds an opengl translation and rotation matrix. | |
void | GLMatrixMultiply (const float a[16], const float b[16], float c[16]) |
Multiply 4*4 matrix by 4*4 matrix. | |
void | GLVectorTransform (const float m[16], const vec4_t in, vec4_t out) |
Multiply 4*4 matrix by 4d vector. | |
void | VectorRotate (vec3_t m[3], const vec3_t va, vec3_t vb) |
Rotate a vector with a rotation matrix. | |
void | ClearBounds (vec3_t mins, vec3_t maxs) |
Sets mins and maxs to their starting points before using AddPointToBounds. | |
void | AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs) |
If the point is outside the box defined by mins and maxs, expand the box to accommodate it. Sets mins and maxs to their new values. | |
int | VectorCompareEps (const vec3_t v1, const vec3_t v2, float epsilon) |
Compare two vectors that may have an epsilon difference but still be the same vectors. | |
qboolean | VectorNearer (const vec3_t v1, const vec3_t v2, const vec3_t comp) |
Checks whether the given vector v1 is closer to comp as the vector v2 . | |
vec_t | VectorLength (const vec3_t v) |
Calculate the length of a vector. | |
void | CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross) |
binary operation on vectors in a three-dimensional space | |
vec_t | VectorNormalize (vec3_t v) |
Calculate unit vector for a given vec3_t. | |
vec_t | VectorNormalize2 (const vec3_t v, vec3_t out) |
Calculated the normal vector for a given vec3_t. | |
void | VectorInverse (vec3_t v) |
Inverse a vector. | |
void | VectorMidpoint (const vec3_t point1, const vec3_t point2, vec3_t midpoint) |
Calculates the midpoint between two vectors. | |
int | Q_log2 (int val) |
float | GetDistanceOnGlobe (const vec2_t pos1, const vec2_t pos2) |
Calculate distance on the geoscape. | |
void | VectorCenterFromMinsMaxs (const vec3_t mins, const vec3_t maxs, vec3_t center) |
Calculates the center of a bounding box. | |
float | VectorAngleBetween (const vec3_t vec1, const vec3_t vec2) |
Calculates the angle (in radians) between the two given vectors. | |
void | VecToAngles (const vec3_t vec, vec3_t angles) |
Converts a vector to an angle vector. | |
void | Print2Vector (const vec2_t v) |
Print a 2D vector. | |
void | Print3Vector (const vec3_t v) |
Print a 3D vector. | |
void | VecToPolar (const vec3_t v, vec2_t a) |
Converts vector coordinates into polar coordinates. | |
void | PolarToVec (const vec2_t a, vec3_t v) |
Converts longitude and latitude to a 3D vector in Euclidean coordinates. | |
void | VectorCreateRotationMatrix (const vec3_t angles, vec3_t matrix[3]) |
void | VectorRotatePoint (vec3_t point, vec3_t matrix[3]) |
void | AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) |
Create the rotation matrix in order to rotate something. | |
float | AngleNormalize360 (float angle) |
returns angle normalized to the range [0 <= angle < 360] | |
float | AngleNormalize180 (float angle) |
returns angle normalized to the range [-180 < angle <= 180] | |
float | LerpAngle (float a1, float a2, float frac) |
Returns the angle resulting from turning fraction * angle from angle1 to angle2. | |
qboolean | FrustumVis (const vec3_t origin, int dir, const vec3_t point) |
Checks whether a point is visible from a given position. | |
void | PerpendicularVector (vec3_t dst, const vec3_t src) |
Finds a vector perpendicular to the source vector. | |
void | RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees) |
Rotate a point around a given vector. | |
float | frand (void) |
Return random values between 0 and 1. | |
float | crand (void) |
Return random values between -1 and 1. | |
void | gaussrand (float *gauss1, float *gauss2) |
generate two gaussian distributed random numbers with median at 0 and stdev of 1 | |
vec_t | Q_rint (const vec_t in) |
Round to nearest integer. | |
vec_t | ColorNormalize (const vec3_t in, vec3_t out) |
void | TangentVectors (const vec3_t normal, const vec3_t sdir, const vec3_t tdir, vec4_t tangent, vec3_t binormal) |
Projects the normalized directional vectors on to the normal's plane. The fourth component of the resulting tangent vector represents sidedness. | |
void | Orthogonalize (vec3_t v1, const vec3_t v2) |
Grahm-Schmidt orthogonalization. | |
void | MatrixTranspose (const vec3_t m[3], vec3_t t[3]) |
Transposes m and stores the result in t . | |
Variables | |
const vec2_t | vec2_origin |
const vec3_t | vec3_origin |
const vec4_t | vec4_origin |
const vec4_t | color_white |
const vec4_t | dvecs [PATHFINDING_DIRECTIONS] |
const float | dvecsn [CORE_DIRECTIONS][2] |
const float | directionAngles [CORE_DIRECTIONS] |
const byte | dvright [CORE_DIRECTIONS] |
const byte | dvleft [CORE_DIRECTIONS] |
Definition in file mathlib.h.
#define AngleToDV | ( | x | ) | (AngleToDir(x) << DV_Z_BIT_SHIFT) |
Definition at line 180 of file mathlib.h.
Referenced by CL_ActorTurnMouse().
#define BASE_DIRECTIONS 4 |
Number of direct connected fields for a position.
Definition at line 98 of file mathlib.h.
Referenced by LE_ActorGetStepTime().
#define CORE_DIRECTIONS 8 |
Definition at line 102 of file mathlib.h.
Referenced by AI_TurnIntoDirection(), AngleToDir(), CheckConnectionsThread(), CMod_LoadRouting(), CMod_RerouteMap(), DoRouting(), G_Actor2x2Spawn(), G_ActorDoTurn(), G_ActorSpawn(), G_ClientMove(), G_ClientShoot(), Grid_MoveMark(), Grid_RecalcBoxRouting(), LE_ActorGetStepTime(), and LE_DoPathMove().
#define COS_ALPHA 0.91706 |
Definition at line 80 of file mathlib.h.
Referenced by CP_CalcAndUploadDayAndNightTexture(), and MAP_IsNight().
#define DIRECTIONS 8 |
Number of angles from a position (2-dimensional).
Definition at line 92 of file mathlib.h.
Referenced by FrustumVis().
#define DotProduct | ( | x, | |||
y | ) | (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) |
Returns the distance between two 3-dimensional vectors.
Definition at line 131 of file mathlib.h.
Referenced by AddBrushBevels(), AdjustBrushesForOrigin(), AI_CheckFF(), AI_FindHerdLocation(), AIR_GetDestinationWhilePursuing(), BaseWindingForPlane(), BrushMostlyOnSide(), BrushVolume(), BuildFaceExtents(), BuildFacelights(), CalcLightinfoVectors(), Check_EdgeEdgeIntersection(), Check_EdgePlaneIntersection(), Check_MapBrushVolume(), Check_PointPlaneDistance(), Check_SidePointsDown(), ChopWindingInPlace(), CL_ActorMouseTrace(), CL_CameraMove(), ClipWindingEpsilon(), CM_HintedTransformedBoxTrace(), FacingAndCoincidentTo(), FinalLightFace(), FindPortalSide(), G_ShootGrenade(), G_ShootSingle(), GatherSampleLight(), GatherSampleSunlight(), MAP_AngleOfPath3D(), NET_WriteDir(), Orthogonalize(), ParallelAndCoincidentTo(), PlaneFromPoints(), ProjectPointOnPlane(), R_CullMeshModel(), R_CullSphere(), R_DrawBspModelSurfaces(), R_DrawFlareSurfaces(), R_FilterTexture(), R_LoadBspVertexArrays(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), R_RecursiveWorldNode(), R_SetSurfaceExtents(), R_SetupFrustum(), RemoveColinearPoints(), RotatePointAroundVector(), S_SpatializeChannel(), SplitBrush(), SubdivideFace(), TangentVectors(), TestBrushToPlanenum(), TestEdge(), TexinfoForBrushTexture(), TextureAxisFromPlane(), TR_BoxOnPlaneSide(), TR_ClipBoxToBrush(), TR_RecursiveHullCheck(), TR_TestBoxInBrush(), TR_TestLine_r(), TryMergeWinding(), VectorAngleBetween(), VectorNormalize(), VectorNormalize2(), and VectorRotatePoint().
#define DV_Z_BIT_MASK ((1 << DV_Z_BIT_SHIFT) - 1) |
#define DV_Z_BIT_SHIFT 3 |
#define EQUAL_EPSILON 0.001 |
Definition at line 34 of file mathlib.h.
Referenced by CP_DrawRadarOverlayRow(), CP_DrawXVIOverlayRow(), TR_TestLineDM(), TR_TileTestLineDM(), and TryMergeWinding().
#define FLYING_DIRECTIONS 16 |
Definition at line 103 of file mathlib.h.
Referenced by AI_TurnIntoDirection(), G_ActorDoTurn(), Grid_MoveMark(), and LE_DoPathMove().
#define getDVdir | ( | dv | ) | (dv >> DV_Z_BIT_SHIFT) |
Definition at line 173 of file mathlib.h.
Referenced by AI_TurnIntoDirection(), CL_ActorDoMoveTime(), CL_GetEventTime(), G_ClientMove(), G_ClientTurn(), HUD_MapDebugCursor(), and LE_DoPathMove().
#define getDVz | ( | dv | ) | (dv & DV_Z_BIT_MASK) |
Definition at line 174 of file mathlib.h.
Referenced by HUD_MapDebugCursor().
#define HIGH_LAT +1.0 |
Definition at line 81 of file mathlib.h.
Referenced by CP_CalcAndUploadDayAndNightTexture().
#define LinearInterpolation | ( | a, | |||
b, | |||||
x, | |||||
y | ) | (y=a[1] + (((x - a[0]) * (b[1] - a[1])) / (b[0] - a[0]))) |
Definition at line 159 of file mathlib.h.
Referenced by MAP_DrawMapMarkers().
#define LOW_LAT -1.0 |
Definition at line 82 of file mathlib.h.
Referenced by CP_CalcAndUploadDayAndNightTexture().
#define makeDV | ( | dir, | |||
z | ) | ((dir << DV_Z_BIT_SHIFT) | (z & DV_Z_BIT_MASK)) |
Definition at line 171 of file mathlib.h.
Referenced by G_EventActorFall(), and Grid_SetMoveData().
#define NewDVZ | ( | dv, | |||
z | ) | ((dv & (~DV_Z_BIT_MASK)) | (z & DV_Z_BIT_MASK)) |
Definition at line 172 of file mathlib.h.
Referenced by G_ClientMove().
#define PATHFINDING_DIRECTIONS 40 |
Definition at line 101 of file mathlib.h.
Referenced by G_ActorDoTurn(), Grid_GetTUsForDirection(), Grid_MoveCalc(), and Grid_MoveMark().
#define PITCH 0 |
Definition at line 73 of file mathlib.h.
Referenced by AngleVectors(), CL_CameraMove(), CL_CamSetAngles_f(), G_ShootGrenade(), G_ShootSingle(), MAP3D_ScreenToMap(), MAP_3DMapToScreen(), MAP_Scroll_f(), R_DrawBrushModel(), R_DrawModelParticle(), R_DrawStarfield(), R_SphereRender(), RotateCelestialBody(), UI_MapNodeCapturedMouseMove(), and VecToAngles().
#define PosAddDV | ( | p, | |||
crouch, | |||||
dv | ) | (p[0]+=dvecs[getDVdir(dv)][0], p[1]+=dvecs[getDVdir(dv)][1], p[2]=getDVz(dv), crouch+=dvecs[getDVdir(dv)][3]) |
Definition at line 176 of file mathlib.h.
Referenced by CL_GetEventTime(), G_ActorShouldStopInMidMove(), G_ClientMove(), and LE_DoPathMove().
#define PosSubDV | ( | p, | |||
crouch, | |||||
dv | ) | (p[0]-=dvecs[getDVdir(dv)][0], p[1]-=dvecs[getDVdir(dv)][1], p[2]=getDVz(dv), crouch-=dvecs[getDVdir(dv)][3]) |
Definition at line 177 of file mathlib.h.
Referenced by CL_ActorMaximumMove(), CL_ActorTraceMove(), G_ClientMove(), and Grid_SetMoveData().
#define PosToVec | ( | p, | |||
v | ) |
( \ v[0] = ((int)p[0] - GRID_WIDTH) * UNIT_SIZE + UNIT_SIZE / 2, \ v[1] = ((int)p[1] - GRID_WIDTH) * UNIT_SIZE + UNIT_SIZE / 2, \ v[2] = (int)p[2] * UNIT_HEIGHT + UNIT_HEIGHT / 2 \ )
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value and multiply with the grid unit size to get back the vector coordinates - now go into the middle of the grid field by adding the half of the grid unit size to this value.
Definition at line 124 of file mathlib.h.
Referenced by CL_ActorMouseTrace(), CL_CameraRoute(), CL_ViewCenterAtGridPosition(), CM_CompleteBoxTrace(), LE_PlayFootStepSound(), LE_PlaySoundFileAndParticleForSurface(), and RT_GetMapSize().
Definition at line 67 of file mathlib.h.
Referenced by CIN_ROQ_Init().
#define ROLL 2 |
Definition at line 75 of file mathlib.h.
Referenced by AngleVectors(), CL_CameraMove(), CL_CamSetAngles_f(), LE_PlaceItem(), R_DrawBrushModel(), R_DrawModelParticle(), R_DrawStarfield(), R_SphereRender(), UI_ModelNodeCapturedMouseMove(), and VecToAngles().
#define SIN_ALPHA 0.39875 |
Definition at line 79 of file mathlib.h.
Referenced by CP_CalcAndUploadDayAndNightTexture(), MAP_IsNight(), and R_Draw3DGlobe().
#define todeg (180.0f/M_PI) |
Definition at line 70 of file mathlib.h.
Referenced by AIR_GetDestinationWhilePursuing(), CL_ActorTurnMouse(), CP_GetCircleDeltaLongitude(), CP_GetRandomPosOnGeoscape(), CP_GetRandomPosOnGeoscapeWithParameters(), G_ClientShoot(), GetDistanceOnGlobe(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_MapCalcLine(), R_DrawStarfield(), S_SpatializeChannel(), VecToAngles(), and VecToPolar().
#define torad (M_PI/180.0f) |
Definition at line 69 of file mathlib.h.
Referenced by AI_CheckFF(), AIR_GetDestinationWhilePursuing(), AngleVectors(), BuildLights(), CL_CameraMove(), CL_GetHitProbability(), Com_GrenadeTarget(), CP_AddRadarCoverage(), CP_GetCircleDeltaLongitude(), CP_IncreaseXVILevel(), CP_UpdateNationXVIInfection(), GetDistanceOnGlobe(), MAP_IsNight(), MAP_MapCalcLine(), Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_CreateRotate(), PolarToVec(), RotatePointAroundVector(), TexinfoForBrushTexture(), and UI_RadarNodeDrawActor().
#define VecToPos | ( | v, | |||
p | ) |
( \ p[0] = ((int)v[0] + MAX_WORLD_WIDTH) / UNIT_SIZE, \ p[1] = ((int)v[1] + MAX_WORLD_WIDTH) / UNIT_SIZE, \ p[2] = min((PATHFINDING_HEIGHT - 1), ((int)v[2] / UNIT_HEIGHT)) \ )
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative value and divide by the size of a grid unit field.
Definition at line 114 of file mathlib.h.
Referenced by CL_ActorMouseTrace(), CMod_RerouteMap(), DoRouting(), G_BuildForbiddenListForEntity(), G_ShootGrenade(), G_ShootSingle(), G_SpawnEntities(), G_SpawnParticle(), and Grid_RecalcRouting().
#define Vector2Compare | ( | a, | |||
b | ) | (a[0]==b[0]?a[1]==b[1]?1:0:0) |
Definition at line 151 of file mathlib.h.
Referenced by CL_TargetingGrenade().
Definition at line 139 of file mathlib.h.
Referenced by AB_BuildBase(), AB_SetAlienBasePosition(), AIR_GetDestinationWhilePursuing(), AIR_Move(), AIR_NewAircraft(), AIR_SendAircraftPursuingUFO(), B_SetUpBase(), CP_BaseAttackGoToBase(), CP_InterceptGoToInstallation(), CP_SpawnAlienBaseMission(), CP_SpawnCrashSiteMission(), CP_SpawnRescueMission(), CP_SupplyGoToBase(), CP_TerrorMissionGo(), INS_SetUpInstallation(), MAP_DrawMap(), MAP_MapClick(), R_FillArrayData(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), R_StageTexCoord(), UFO_CampaignRunUFOs(), UFO_SetRandomPos(), UI_BaseInventoryNodeDrawItems(), UI_BaseInventoryNodeGetItem(), UI_EKGNodeDraw(), UI_ImageNodeDraw(), and UI_InitRadar().
#define Vector2Dist | ( | a, | |||
b | ) | (sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))) |
Definition at line 155 of file mathlib.h.
Referenced by UI_InitRadar().
#define Vector2Equal | ( | a, | |||
b | ) | (equal(a[0],b[0])?equal(a[1],b[1])?1:0:0) |
Definition at line 152 of file mathlib.h.
Referenced by R_ModCalcUniqueNormalsAndTangents().
#define Vector2Set | ( | v, | |||
x, | |||||
y | ) | ((v)[0]=(x), (v)[1]=(y)) |
Definition at line 147 of file mathlib.h.
Referenced by B_BuildFromTemplate(), CP_GetRandomPosOnGeoscapeWithParameters(), CP_UpdateNationXVIInfection(), MAP3D_ScreenToMap(), MAP_3DMapToScreen(), MAP_ConvertObjectPositionToGeoscapePosition(), MAP_MapCalcLine(), MAP_StartCenter(), R_FontGenerateTexture(), R_SetSurfaceExtents(), R_SphereGenerate(), U2M_SetDefaultConfigValues(), UFO_SetRandomDestAround(), UI_EKGNodeDraw(), UI_GetNodeAbsPos(), UI_GetRadarWidth(), UI_ImageNodeDraw(), UI_KeyBindingNodeDraw(), and UI_SetNewWindowPos().
Definition at line 133 of file mathlib.h.
Referenced by R_ModCalcNormalsAndTangents(), and R_ModCalcUniqueNormalsAndTangents().
#define Vector4Clear | ( | a | ) | ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0) |
Definition at line 143 of file mathlib.h.
Referenced by R_CreateFramebuffer(), and R_InitFBObjects().
Definition at line 140 of file mathlib.h.
Referenced by CL_NationDrawStats(), CL_NationStatsUpdate_f(), MAP_DrawAircraftHealthBar(), R_ModCalcNormalsAndTangents(), TR_TransferAliensFromMission_f(), UI_BarNodeDraw(), UI_ContainerNodeDrawSingle(), UI_DrawItem(), and UI_DrawModelNodeWithUIModel().
#define Vector4NotEmpty | ( | a | ) | (a[0]||a[1]||a[2]||a[3]) |
Definition at line 158 of file mathlib.h.
Referenced by R_SphereShadeGLSL().
#define Vector4Set | ( | v, | |||
r, | |||||
g, | |||||
b, | |||||
a | ) | (v[0]=(r), v[1]=(g), v[2]=(b), v[3]=(a)) |
Definition at line 148 of file mathlib.h.
Referenced by CL_ParticleRun2(), CL_ParticleSpawn(), Grid_MoveCalc(), Grid_SetMoveData(), R_BuildDefaultLightmap(), R_Draw3DGlobe(), R_DrawEntityEffects(), R_StageColor(), RotateCelestialBody(), SP_worldspawn(), UI_BarNodeLoading(), UI_BaseLayoutNodeLoading(), UI_ButtonNodeLoading(), UI_KeyBindingNodeLoading(), UI_MapNodeLoading(), UI_ModelNodeLoading(), UI_OptionListNodeLoading(), UI_OptionTreeNodeLoading(), UI_ParseUIModel(), UI_RadarNodeDrawActor(), UI_RadarNodeDrawItem(), UI_RadarNodeGetActorColor(), UI_SelectBoxNodeLoading(), UI_StringNodeLoading(), UI_TextEntryNodeLoading(), UI_TextListNodeLoading(), UI_TextNodeLoading(), and UI_TodoNodeLoading().
Definition at line 134 of file mathlib.h.
Referenced by AI_CheckFF(), BaseWindingForPlane(), BuildPatches(), BuildVertexNormals(), CalcLightinfoVectors(), Check_EdgeEdgeIntersection(), Check_EdgePlaneIntersection(), CL_ActorMouseTrace(), CL_AddTargetingBox(), CL_TargetingGrenade(), CM_CalculateBoundingBox(), CM_CompleteBoxTrace(), CM_EntCompleteBoxTrace(), CM_HintedTransformedBoxTrace(), CMod_LoadEntityString(), ConstructLevelNodes_r(), FinalLightFace(), G_BuildForbiddenListForEntity(), G_ShootGrenade(), G_ShootSingle(), Grid_RecalcRouting(), LE_AddToScene(), MAP3D_SmoothRotate(), R_CullBspModel(), R_CullMeshModel(), R_DrawFlareSurfaces(), R_DrawSprite(), R_EntityAddToOrigin(), R_LoadBspVertexArrays(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), RT_CheckCell(), RT_GetMapSize(), SV_LinkEdict(), SV_StartSound(), TR_BoxTrace(), UI_InitRadar(), VectorCenterFromMinsMaxs(), VectorMidpoint(), and WindingCenter().
#define VectorClear | ( | a | ) | ((a)[0]=(a)[1]=(a)[2]=0) |
Definition at line 142 of file mathlib.h.
Referenced by AddBrushBevels(), BrushFromBounds(), BuildLights(), BuildVertexNormals(), ChopWindingInPlace(), CL_CameraMove(), CL_CameraRoute(), ClipWindingEpsilon(), CM_InitBoxHull(), ColorNormalize(), GetVectorFromString(), MakeBrushWindings(), R_ModCalcNormalsAndTangents(), SnapVector(), SubdividePatch(), and TR_BoxTrace().
#define VectorCompare | ( | a, | |||
b | ) | (a[0]==b[0]?a[1]==b[1]?a[2]==b[2]?1:0:0:0) |
Definition at line 149 of file mathlib.h.
Referenced by AI_FindHerdLocation(), BuildFacelights(), BuildLights(), CL_ActorMouseTrace(), CL_ActorMoveMouse(), CL_ActorSearchAtGridPos(), CL_ActorSelectMouse(), CL_EntPerish(), CP_UpdateNationXVIInfection(), G_ClientMove(), G_EdictPosIsSameAs(), G_GetEdictFromPos(), G_Vis(), Grid_CheckForbidden(), Grid_SetMoveData(), LE_DoEndPathMove(), LE_Find(), LE_GetFromPos(), LE_PlaceItem(), MAP_GetNation(), R_LoadBspVertexArrays(), and TR_BoxTrace().
Definition at line 138 of file mathlib.h.
Referenced by AI_CheckForMissionTargets(), AI_CivilianCalcBestAction(), AI_FighterCalcBestAction(), AI_FindHerdLocation(), AI_PrepBestAction(), AIL_positionherd(), AIL_positionhide(), AIL_positionshoot(), AIR_MoveAircraftIntoNewHomebase(), AIRFIGHT_CampaignRunProjectiles(), AIRFIGHT_MissTarget(), BaseWindingForPlane(), BeginModel(), BrushVolume(), BuildFacelights(), BuildLights(), BuildNodeChildren(), BuildPatch(), BuildPatches(), CalcLightinfoVectors(), CalcTextureReflectivity(), Check_MapBrushVolume(), Check_SidesOverlap(), CheckNodraws(), ChopWindingInPlace(), CL_ActorAppear(), CL_ActorDie(), CL_ActorMaximumMove(), CL_ActorMouseTrace(), CL_ActorMoveMouse(), CL_ActorRevitalised(), CL_ActorSelectMouse(), CL_ActorStateChange(), CL_ActorTraceMove(), CL_ActorVis(), CL_AddArrow(), CL_AddBrushModel(), CL_AddEdict(), CL_AddEdictFunc(), CL_AddMapParticle(), CL_CameraRoute(), CL_ClipMoveToLEs(), CL_DisplayFloorArrows(), CL_DisplayObstructionArrows(), CL_DrawLineOfSight(), CL_EntAppear(), CL_GetEventTime(), CL_GetHitProbability(), CL_HullForEntity(), CL_ParticleRun2(), CL_ParticleRunTimed(), CL_ParticleSpawn(), CL_TargetingGrenade(), CL_TargetingStraight(), CL_ViewCenterAtGridPosition(), CL_ViewUpdateRenderData(), ClipWindingEpsilon(), CM_EntTestLineDM(), CM_HintedTransformedBoxTrace(), CM_SetInlineModelOrientation(), CMod_LoadSubmodels(), ConstructLevelNodes_r(), CP_BaseAttackStartMission(), CreateNewFloatPlane(), DoRouting(), EmitBrushes(), EmitDrawNode_r(), EmitFaceVertexes(), EmitLeaf(), EmitPlanes(), FinalLightFace(), FinishSubdividePatch(), FixFaceEdges(), FixWinding(), G_ActorShouldStopInMidMove(), G_ActorVis(), G_ClientMove(), G_EdictSetOrigin(), G_PhysicsStep(), G_ShootGrenade(), G_ShootSingle(), G_SpawnFloor(), G_SpawnParticle(), G_SplashDamage(), G_TeamPointVis(), G_TriggerSpawn(), G_Vis(), Grid_MoveCalc(), LE_AddAmbientSound(), LE_AddToScene(), LE_BrushModelAction(), LE_CenterView(), LE_PlayFootStepSound(), LET_PathMove(), LET_Projectile(), LM_AddModel(), LM_AddToSceneOrder(), MakeBspBrushList(), MakeNodePortal(), MAP3D_SmoothRotate(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_DrawMapMarkers(), MAP_DrawMapOnePhalanxAircraft(), MAP_Scroll_f(), MAP_Zoom_f(), NET_ReadDir(), NudgeSamplePosition(), ParseBrush(), R_AddCorona(), R_AddLight(), R_AddSustainedLight(), R_CreateSurfaceFlare(), R_CullBspModel(), R_CullMeshModel(), R_Draw2DMapMarkers(), R_Draw3DGlobe(), R_Draw3DMapMarkers(), R_DrawArrow(), R_DrawBox(), R_DrawBrushModel(), R_DrawFloor(), R_DrawSprite(), R_EnableLights(), R_EntityCopyOrigin(), R_EntitySetOrigin(), R_FillArrayData(), R_FilterTexture(), R_LoadBspVertexArrays(), R_LoadObjModelVertexArrays(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), R_ModLoadAliasDPMModel(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), R_ModLoadSurfaces(), R_SetSurfaceExtents(), R_SetSurfaceStageState(), R_SetupSubmodels(), R_ShiftLights(), R_SortLightList(), R_StageColor(), R_StageVertex(), RemoveColinearPoints(), ReverseWinding(), RT_CheckCell(), RT_FindOpening(), RT_FindOpeningCeilingFrac(), RT_FindOpeningFloorFrac(), RT_GetMapSize(), S_LoopSample(), S_PlaySample(), SampleNormal(), SEQ_Render3D(), SEQ_SetCamera(), SP_light(), SP_misc_model(), SP_worldspawn(), SubdivideFace(), SV_CreateWorldSector(), SV_HullForEntity(), SV_LinkEdict(), SV_LoadModelMinsMaxs(), SV_SetModel(), SV_StartSound(), TangentVectors(), TestBrushToPlanenum(), TestEdge(), TextureAxisFromPlane(), TR_BoxTrace(), TR_BuildTracingNode_r(), TR_MakeTracingNode(), TR_TestLineDist_r(), TR_TestLineDM(), TR_TileTestLineDM(), TryMergeWinding(), UI_DrawItem(), UI_InitModelInfoView(), UI_RadarNodeCapturedMouseMove(), UI_Transform(), VectorRotatePoint(), WindingCenter(), and WindingFromFace().
#define VectorDist | ( | a, | |||
b | ) | (sqrt((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 154 of file mathlib.h.
Referenced by AI_CheckCrouch(), AI_CheckForMissionTargets(), AI_CheckUsingDoor(), AI_CivilianCalcBestAction(), AI_FighterCalcBestAction(), AI_FighterCheckShoot(), AIL_distance(), CL_ActorDoShootTime(), CL_CameraMove(), CL_GetEventTime(), CL_TargetingStraight(), G_ClientShoot(), G_Morale(), G_ReactionFireGetTUsForItem(), G_SplashDamage(), and R_AddEntity().
#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])) |
Definition at line 153 of file mathlib.h.
Referenced by AI_FindHerdLocation(), AI_HideNeeded(), AIL_see(), Check_LongestEdge(), CheckNodraws(), CL_TargetingStraight(), G_ReactionFireIsPossible(), G_Vis(), and R_LightDistCompare().
#define VectorDiv | ( | in, | |||
scalar, | |||||
out | ) | VectorScale(in,(1.0f/(scalar)),out) |
#define VectorEqual | ( | a, | |||
b | ) | (equal(a[0],b[0])?equal(a[1],b[1])?equal(a[2],b[2])?1:0:0:0) |
Definition at line 150 of file mathlib.h.
Referenced by R_ModCalcUniqueNormalsAndTangents().
#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 161 of file mathlib.h.
Referenced by CM_HintedTransformedBoxTrace(), RT_FindOpening(), RT_FindOpeningCeilingFrac(), RT_FindOpeningFloorFrac(), TR_BoxTrace(), TR_RecursiveHullCheck(), TR_TestLine_r(), and TR_TestLineDist_r().
#define VectorLengthSqr | ( | a | ) | (a[0]*a[0]+a[1]*a[1]+a[2]*a[2]) |
Definition at line 156 of file mathlib.h.
Referenced by Check_PointPlaneDistance().
#define VectorMul | ( | scalar, | |||
b, | |||||
dest | ) | (dest[0]=(scalar)*b[0],dest[1]=(scalar)*b[1],dest[2]=(scalar)*b[2]) |
Definition at line 135 of file mathlib.h.
Referenced by Check_EdgePlaneIntersection(), Orthogonalize(), R_ModCalcNormalsAndTangents(), and R_ModCalcUniqueNormalsAndTangents().
Definition at line 144 of file mathlib.h.
Referenced by BuildFacelights(), BuildPatch(), CM_HintedTransformedBoxTrace(), R_ModelAutoScale(), R_ModLoadSurfaces(), and UI_DrawItem().
#define VectorNotEmpty | ( | a | ) | (a[0]||a[1]||a[2]) |
Definition at line 157 of file mathlib.h.
Referenced by CL_ParticleRun2(), CM_CalculateBoundingBox(), CM_HintedTransformedBoxTrace(), Grid_RecalcRouting(), ParseMapEntity(), PlaneFromPoints(), R_DrawBox(), R_DrawBrushModel(), R_DrawMeshModelShell(), R_ModAddMapTile(), R_SphereRender(), and SV_LinkEdict().
#define VectorScale | ( | in, | |||
scale, | |||||
out | ) | ((out)[0] = (in)[0] * (scale),(out)[1] = (in)[1] * (scale),(out)[2] = (in)[2] * (scale)) |
Definition at line 160 of file mathlib.h.
Referenced by AI_CheckFF(), BaseWindingForPlane(), BuildVertexNormals(), CalcLightinfoVectors(), Check_EdgeEdgeIntersection(), CL_ActorMouseTrace(), CL_CameraMove(), CL_TargetingGrenade(), ColorNormalize(), Com_GrenadeTarget(), EmissiveLight(), FinalLightFace(), G_ShootGrenade(), G_ShootSingle(), LE_AddProjectile(), MAP3D_SmoothRotate(), R_AddSustainedLights(), R_DrawFlareSurfaces(), R_FilterTexture(), R_GetSpriteVectors(), R_SetupFrustum(), SP_worldspawn(), TangentVectors(), TexinfoForBrushTexture(), UI_BarNodeDraw(), UI_DrawItem(), UI_ImageNodeDraw(), UI_TextLineNodeDrawText(), UI_TextNodeDrawText(), VectorCenterFromMinsMaxs(), VectorMidpoint(), and WindingCenter().
#define VectorSet | ( | v, | |||
x, | |||||
y, | |||||
z | ) | ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) |
Definition at line 145 of file mathlib.h.
Referenced by AIR_AircraftMakeMove(), AIR_NewAircraft(), AIRFIGHT_AddProjectile(), BuildFaceExtents(), BuildFacelights(), CalcTextureReflectivity(), Check_MapSize(), CL_ActorMouseTrace(), CL_ActorSearchAtGridPos(), CL_AddArrow(), CL_AddEdictFunc(), CL_AddPathingBox(), CL_AddTargetingBox(), CL_CameraMove(), CL_DisplayHomebasePopup(), CL_DrawLineOfSight(), CL_SpawnParseEntitystring(), CL_StartGame(), CL_ViewLoadMedia(), CM_AddMapTile(), CM_CalculateBoundingBox(), CM_EntCompleteBoxTrace(), DoRouting(), FinalLightFace(), G_Actor2x2Spawn(), G_ActorSetMaxs(), G_ActorSpawn(), G_BuildForbiddenListForEntity(), Grid_SetMoveData(), HUD_PopupFiremodeReservation(), LE_AddGrenade(), MAP3D_ScreenToMap(), MAP_3DMapToScreen(), MAP_AngleOfPath2D(), MAP_ConvertObjectPositionToGeoscapePosition(), MAP_Draw3DMarkerIfVisible(), MAP_MapCalcLine(), PolarToVec(), R_Draw3DGlobe(), R_DrawStarfield(), R_FillArrayData(), R_FilterTexture(), R_ModAddMapTile(), R_ModelAutoScale(), R_SetSurfaceExtents(), R_SetSurfaceStageState(), R_SphereGenerate(), R_StageColor(), R_Trace(), RotateCelestialBody(), RT_CheckCell(), RT_FindOpening(), RT_GetMapSize(), RT_MicroTrace(), RT_ObstructedTrace(), SEQ_ExecuteModel(), SP_2x2_start(), SP_misc_mission(), SP_misc_mission_aliens(), TR_BuildTracingNode_r(), U2M_SetDefaultConfigValues(), UI_DrawDragAndDrop(), UI_InitRadar(), and UI_ModelNodeLoading().
Definition at line 132 of file mathlib.h.
Referenced by AddBrushBevels(), AI_CheckFF(), AI_FindHerdLocation(), BaseWindingForNode(), BaseWindingForPlane(), BuildLights(), BuildVertexNormals(), CalcLightinfoVectors(), Check_EdgeEdgeIntersection(), Check_EdgePlaneIntersection(), Check_MapSize(), Check_SidesOverlap(), CL_ActorMouseTrace(), CL_ActorTurnMouse(), CL_AddPathingBox(), CL_AddTargetingBox(), CL_CameraRoute(), CL_TargetingGrenade(), CL_TargetingStraight(), CM_CalculateBoundingBox(), CM_CompleteBoxTrace(), CM_HintedTransformedBoxTrace(), CMod_LoadEntityString(), Com_GrenadeTarget(), ConstructLevelNodes_r(), CreateNewFloatPlane(), FixFaceEdges(), FixWinding(), G_ClientShoot(), G_ShootSingle(), GatherSampleLight(), Grid_RecalcRouting(), LE_AddProjectile(), LE_PlaceItem(), LET_PathMove(), MakeNodePortal(), MAP3D_SmoothRotate(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_Scroll_f(), MAP_StartCenter(), NudgeSamplePosition(), Orthogonalize(), PlaneFromPoints(), R_CreateSurfaceFlare(), R_DrawBrushModel(), R_DrawFlareSurfaces(), R_DrawSprite(), R_EnableLights(), R_EntitySubtractFromOrigin(), R_GetLevelOfDetailForModel(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), R_StageTexCoord(), RemoveColinearPoints(), RT_GetMapSize(), S_LoopSample(), S_SpatializeChannel(), SampleNormal(), SV_CreateWorldSector(), SV_LinkEdict(), TestEdge(), TR_BoxTrace(), TryMergeWinding(), UI_InitRadar(), VectorCompareEps(), VectorNearer(), WindingArea(), and WindingIsTiny().
#define VectorSum | ( | a | ) | ((a)[0]+(a)[1]+(a)[2]) |
Definition at line 146 of file mathlib.h.
Referenced by SP_worldspawn().
#define YAW 1 |
Definition at line 74 of file mathlib.h.
Referenced by AngleVectors(), CL_ActorAppear(), CL_ActorDoTurn(), CL_CameraMove(), CL_CamSetAngles_f(), CL_DoorClose(), CL_DoorOpen(), CP_CampaignInit(), Door_Use(), G_ShootGrenade(), G_ShootSingle(), LE_DoPathMove(), MAP3D_ScreenToMap(), MAP_3DMapToScreen(), MAP_Scroll_f(), R_CullMeshModel(), R_DrawBrushModel(), R_DrawModelParticle(), R_DrawStarfield(), R_SphereRender(), RotateCelestialBody(), UI_MapNodeCapturedMouseMove(), UI_ModelNodeCapturedMouseMove(), and VecToAngles().
If the point is outside the box defined by mins and maxs, expand the box to accommodate it. Sets mins and maxs to their new values.
Definition at line 955 of file mathlib.c.
References i.
Referenced by BeginModel(), BoundBrush(), BrushBSP(), BuildNodeChildren(), CalcNodeBounds(), Check_MapSize(), LoadMapFile(), MakeBrushWindings(), MapBrushesBounds(), R_LoadObjModel(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), R_ModLoadAliasMD3Model(), SV_ModLoadAliasMD2Model(), and SV_ModLoadAliasMD3Model().
float AngleNormalize180 | ( | float | angle | ) |
returns angle normalized to the range [-180 < angle <= 180]
[in] | angle | Angle |
Definition at line 921 of file mathlib.c.
References AngleNormalize360().
float AngleNormalize360 | ( | float | angle | ) |
returns angle normalized to the range [0 <= angle < 360]
[in] | angle | Angle |
Definition at line 912 of file mathlib.c.
References int().
Referenced by AngleNormalize180().
int AngleToDir | ( | int | angle | ) |
Returns the indice of array directionAngles[DIRECTIONS] whose value is the closest to angle.
[in] | angle | The angle (in degrees) which is tested. |
Definition at line 112 of file mathlib.c.
References Com_Printf(), and CORE_DIRECTIONS.
Referenced by G_Actor2x2Spawn(), G_ActorSpawn(), and G_ClientShoot().
Create the rotation matrix in order to rotate something.
[in] | angles | Contains the three angles PITCH, YAW and ROLL (in degree) of rotation around idle frame ({0, 1, 0}, {0, 0, 1} ,{1, 0, 0}) (in this order!) |
[out] | forward | return the first line of the rotation matrix. |
[out] | right | return the second line of the rotation matrix. |
[out] | up | return the third line of the rotation matrix. |
right
). Exemple : to rotate v2 into v : AngleVectors(angles, m[0], m[1], m[2]); VectorInverse(m[1]); VectorRotate(m, v2, v); Definition at line 562 of file mathlib.c.
References PITCH, ROLL, torad, and YAW.
Referenced by BuildLights(), CL_CameraMove(), CM_HintedTransformedBoxTrace(), G_ShootGrenade(), G_ShootSingle(), GLMatrixAssemble(), R_CullMeshModel(), R_GetSpriteVectors(), R_SetupFrustum(), S_Frame(), SEQ_SetCamera(), U2M_SetDefaultConfigValues(), and VectorCreateRotationMatrix().
Sets mins and maxs to their starting points before using AddPointToBounds.
Definition at line 945 of file mathlib.c.
Referenced by AllocTree(), BeginModel(), BoundBrush(), BuildNodeChildren(), CalcNodeBounds(), LoadMapFile(), MakeBrushWindings(), MapBrushesBounds(), ProcessWorldModel(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), and SV_LoadModelMinsMaxs().
Definition at line 172 of file mathlib.c.
References VectorClear, and VectorScale.
Referenced by BuildLights(), and U2M_SetDefaultConfigValues().
float crand | ( | void | ) |
Return random values between -1 and 1.
Definition at line 488 of file mathlib.c.
Referenced by AI_HideNeeded(), CL_ParticleFunction(), G_ShootGrenade(), G_ShootSingle(), gaussrand(), and LE_AddGrenade().
binary operation on vectors in a three-dimensional space
[in] | v1 | directional vector |
[in] | v2 | directional vector |
[out] | cross | output |
Definition at line 719 of file mathlib.c.
Referenced by AddBrushBevels(), AIR_GetDestinationWhilePursuing(), BaseWindingForPlane(), Check_EdgeEdgeIntersection(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_MapCalcLine(), PlaneFromPoints(), R_GetSpriteVectors(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), RotatePointAroundVector(), TangentVectors(), TryMergeWinding(), and WindingArea().
float frand | ( | void | ) |
Return random values between 0 and 1.
Definition at line 477 of file mathlib.c.
Referenced by AI_CheckUsingDoor(), AI_CivilianCalcBestAction(), AI_InitPlayer(), AI_SearchBestTarget(), AIRFIGHT_BaseShoot(), AIRFIGHT_ExecuteActions(), AIRFIGHT_InstallationShoot(), AIRFIGHT_MissTarget(), B_BuildFromTemplate(), B_Destroy_AntimaterStorage_f(), CHRSH_CharGenAbilitySkills(), CL_AddMapParticle(), CL_GameAutoGo(), CL_ParticleFunction(), CL_RunMapParticles(), CP_BaseAttackChooseBase(), CP_CheckNewMissionDetectedOnGeoscape(), CP_ChooseNation(), CP_CreateBattleParameters(), CP_GetRandomPosOnGeoscape(), CP_GetRandomPosOnGeoscapeWithParameters(), CP_InterceptChooseInstallation(), CP_InterceptMissionAvailableUFOs(), CP_MissionChooseUFO(), CP_ReconMissionChoose(), CP_ReconMissionNewGroundMission(), CP_SelectNewMissionType(), CP_SpawnNewMissions(), Date_Random(), E_InitialEmployees(), G_GetStartingTeam(), G_MoraleBehaviour(), G_MoraleStopPanic(), G_MoraleStopRage(), G_ReactionFireIsPossible(), I_EquipActor(), RADAR_CheckUFOSensored(), SP_alien_start(), and UR_DialogInitSell_f().
Checks whether a point is visible from a given position.
[in] | origin | Origin to test from |
[in] | dir | Direction to test into |
[in] | point | This is the point we want to check the visibility for |
Definition at line 597 of file mathlib.c.
References byte, DIRECTIONS, dvecsn, qfalse, qtrue, and VectorNormalize().
Referenced by G_FrustumVis().
void gaussrand | ( | float * | gauss1, | |
float * | gauss2 | |||
) |
generate two gaussian distributed random numbers with median at 0 and stdev of 1
[out] | gauss1 | First gaussian distributed random number |
[out] | gauss2 | Second gaussian distributed random number |
Definition at line 500 of file mathlib.c.
Referenced by G_ShootSingle(), and UFO_SetRandomDestAround().
Calculate distance on the geoscape.
[in] | pos1 | Position at the start. |
[in] | pos2 | Position at the end. |
Definition at line 154 of file mathlib.c.
Referenced by AB_SetAlienBasePosition(), AB_UpdateStealthForOneBase(), AIR_AircraftHasEnoughFuel(), AIR_AircraftHasEnoughFuelOneWay(), AIR_GetDestinationWhilePursuing(), AIRFIGHT_BaseShoot(), AIRFIGHT_ChooseWeapon(), AIRFIGHT_InstallationShoot(), AIRFIGHT_MissTarget(), AIRFIGHT_ProjectileReachedTarget(), BDEF_AutoTarget(), CL_DisplayPopupInterceptMission(), CP_DrawXVIOverlayPixel(), MAP_GetAircraftText(), MAP_PositionCloseToBase(), PR_CalculateProductionPercentDone(), RADAR_AddDetectedUFOToEveryRadar(), RADAR_CheckRadarSensored(), RADAR_CheckUFOSensored(), TR_TransferAlienAfterMissionStart(), TR_TransferStart(), UFO_CampaignCheckEvents(), UFO_SearchAircraftTarget(), UFO_UpdateAlienInterestForOneBase(), UFO_UpdateAlienInterestForOneInstallation(), and US_GetClosestStoredUFO().
Builds an opengl translation and rotation matrix.
origin | The translation vector | |
angles | The angle vector that is used to calculate the rotation part of the matrix | |
matrix | The resulting matrix, must be of dimension 16 |
Definition at line 307 of file mathlib.c.
References AngleVectors(), and VectorInverse().
Referenced by CL_ActorGetMuzzle(), and R_CalcTransform().
void GLMatrixMultiply | ( | const float | a[16], | |
const float | b[16], | |||
float | c[16] | |||
) |
Multiply 4*4 matrix by 4*4 matrix.
[out] | c | The result of the multiplication matrix = a * b (not the same as b * a as matrix multiplication is not commutative) |
[in] | a | First matrix. |
[in] | b | Second matrix. |
Definition at line 332 of file mathlib.c.
References i.
Referenced by CL_ActorGetMuzzle(), and R_CalcTransform().
Multiply 4*4 matrix by 4d vector.
[out] | out | the result of the multiplication = m * in . |
[in] | m | 4*4 matrix |
[in] | in | 4d vector. |
Definition at line 350 of file mathlib.c.
References i.
float LerpAngle | ( | float | a1, | |
float | a2, | |||
float | frac | |||
) |
Multiply 3*3 matrix by 3*3 matrix.
[out] | c | The result of the multiplication matrix = a * b (not the same as b * a !) |
[in] | a | First matrix. |
[in] | b | Second matrix. |
Grahm-Schmidt orthogonalization.
[out] | v1 | |
[in] | v2 |
Definition at line 1004 of file mathlib.c.
References DotProduct, VectorMul, VectorNormalize(), and VectorSubtract.
Referenced by R_ModCalcNormalsAndTangents(), and R_ModCalcUniqueNormalsAndTangents().
Finds a vector perpendicular to the source vector.
[in] | src | The source vector |
[out] | dst | A vector perpendicular to src |
dst
is a perpendicular vector to src
such that it is the closest to one of the three axis: {1,0,0}, {0,1,0} and {0,0,1} (chosen in that order in case of equality) src
is normalized Definition at line 680 of file mathlib.c.
References i, pos, ProjectPointOnPlane(), and VectorNormalize().
Referenced by MAP_MapDrawEquidistantPoints(), and RotatePointAroundVector().
Converts longitude and latitude to a 3D vector in Euclidean coordinates.
[in] | a | The longitude and latitude in a 2D vector |
[out] | v | The resulting normal 3D vector |
Definition at line 827 of file mathlib.c.
References torad, and VectorSet.
Referenced by AIR_GetDestinationWhilePursuing(), AIRFIGHT_GetNextPointInPathFromVector(), MAP_3DMapToScreen(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_MapCalcLine(), and MAP_MapDrawEquidistantPoints().
void Print2Vector | ( | const vec2_t | v | ) |
Print a 2D vector.
[in] | v | The vector to be printed |
Definition at line 815 of file mathlib.c.
References Com_Printf().
void Print3Vector | ( | const vec3_t | v | ) |
Print a 3D vector.
[in] | v | The vector to be printed |
Definition at line 806 of file mathlib.c.
References Com_Printf().
Referenced by Check_SidesOverlap().
qboolean Q_IsPowerOfTwo | ( | int | i | ) |
Checks whether i is power of two value.
Definition at line 889 of file mathlib.c.
Referenced by CIN_ROQ_DecodeInfo(), and R_CvarCheckMaxLightmap().
Round to nearest integer.
Definition at line 138 of file mathlib.c.
Referenced by GetVertexnum(), and SnapPlane().
Rotate a point around a given vector.
[in] | dir | The vector around which to rotate |
[in] | point | The point to be rotated |
[in] | degrees | How many degrees to rotate the point by |
[out] | dst | The point after rotation |
dst
must be different from point
(otherwise the result has no meaning) dir
must be normalized Definition at line 748 of file mathlib.c.
References CrossProduct(), DotProduct, i, m, PerpendicularVector(), R_ConcatRotations(), and torad.
Referenced by AIR_GetDestinationWhilePursuing(), AIRFIGHT_GetNextPointInPathFromVector(), MAP3D_ScreenToMap(), MAP_3DMapToScreen(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_MapDrawEquidistantPoints(), R_SetupFrustum(), and RotateCelestialBody().
void TangentVectors | ( | const vec3_t | normal, | |
const vec3_t | sdir, | |||
const vec3_t | tdir, | |||
vec4_t | tangent, | |||
vec3_t | binormal | |||
) |
Projects the normalized directional vectors on to the normal's plane. The fourth component of the resulting tangent vector represents sidedness.
Definition at line 973 of file mathlib.c.
References CrossProduct(), DotProduct, VectorCopy, VectorMA(), VectorNormalize(), and VectorScale.
Referenced by BuildFacelights(), and R_LoadBspVertexArrays().
Converts a vector to an angle vector.
[in] | value1 | |
[in] | angles | Target vector for pitch, yaw, roll |
Definition at line 851 of file mathlib.c.
References int(), PITCH, ROLL, todeg, and YAW.
Referenced by G_ShootGrenade(), G_ShootSingle(), LE_AddProjectile(), and LET_Projectile().
Converts vector coordinates into polar coordinates.
Definition at line 839 of file mathlib.c.
References todeg.
Referenced by AIR_GetDestinationWhilePursuing(), AIRFIGHT_GetNextPointInPathFromVector(), MAP3D_ScreenToMap(), MAP_MapCalcLine(), and MAP_MapDrawEquidistantPoints().
Calculates the angle (in radians) between the two given vectors.
Definition at line 455 of file mathlib.c.
References DotProduct.
Calculates the center of a bounding box.
[in] | mins | The lower end of the bounding box |
[in] | maxs | The upper end of the bounding box |
[out] | center | The target center vector calculated from mins and maxs |
Definition at line 935 of file mathlib.c.
References VectorAdd, and VectorScale.
Referenced by CL_CenterCameraIntoMap_f(), CM_CalculateBoundingBox(), Destroy_Breakable(), G_BuildForbiddenListForEntity(), G_SplashDamage(), Grid_RecalcRouting(), ParseBrush(), R_ModelAutoScale(), R_SetSurfaceExtents(), SV_LinkEdict(), SV_StartSound(), and TR_BoxTrace().
Definition at line 250 of file mathlib.c.
References f, i, and VectorMA().
Compare two vectors that may have an epsilon difference but still be the same vectors.
[in] | v1 | vector to compare with v2 |
[in] | v2 | vector to compare with v1 |
[in] | epsilon | The epsilon the vectors may differ to still be the same |
Definition at line 385 of file mathlib.c.
References VectorSubtract.
Referenced by CP_InterceptAttackInstallation(), CP_InterceptMissionLeave(), MAP_MapCalcLine(), TR_TestLineDM(), and TR_TileTestLineDM().
angles | The angles to calulcate the rotation matrix for | |
matrix | The resulting rotation matrix. The right part of this matrix is inversed because of the coordinate system we are using internally. |
Definition at line 523 of file mathlib.c.
References AngleVectors(), and VectorInverse().
Referenced by Grid_RecalcRouting(), R_DrawBrushModel(), and SV_LinkEdict().
void VectorInverse | ( | vec3_t | v | ) |
Inverse a vector.
[in,out] | v | Vector to inverse. Output value is -v . |
Definition at line 431 of file mathlib.c.
Referenced by GLMatrixAssemble(), and VectorCreateRotationMatrix().
Calculate the length of a vector.
[in] | v | Vector to calculate the length of |
Definition at line 406 of file mathlib.c.
Referenced by BuildVertexNormals(), CalcLightinfoVectors(), Check_EdgeEdgeIntersection(), Check_EdgePlaneIntersection(), Check_SidesOverlap(), CL_CameraMove(), CL_CameraRoute(), CL_TargetingGrenade(), Com_GrenadeTarget(), CreateNewFloatPlane(), FixWinding(), G_FindRadius(), G_ShootGrenade(), LE_AddProjectile(), LE_FindRadius(), MAP3D_SmoothRotate(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_Scroll_f(), MAP_StartCenter(), R_CreateSurfaceFlare(), R_GetLevelOfDetailForModel(), R_RadiusFromBounds(), R_StageColor(), S_LoopSample(), SampleNormal(), TestEdge(), VectorNearer(), WindingArea(), and WindingIsTiny().
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb).
[in] | veca | Position to start from |
[in] | scale | Speed of the movement |
[in] | vecb | Movement direction |
[out] | outVector | Target vector |
Definition at line 243 of file mathlib.c.
Referenced by BaseWindingForPlane(), BuildPatch(), CalcLightinfoVectors(), CL_ActorMouseTrace(), CL_ActorVis(), CL_CameraMove(), CL_ParticleRun2(), CL_TargetingStraight(), FinishSubdividePatch(), G_ActorVis(), G_ClientShoot(), G_ShootGrenade(), G_ShootSingle(), G_SplashDamage(), GatherSampleLight(), GatherSampleSunlight(), LE_AddProjectile(), LET_PathMove(), NudgeSamplePosition(), R_CreateSurfaceFlare(), R_DrawBspNormals(), R_DrawSprite(), R_ModLoadAliasMD2MeshIndexed(), R_ModLoadAliasMD2MeshUnindexed(), SEQ_Render3D(), SEQ_SetCamera(), SV_ModLoadAliasMD2Model(), TangentVectors(), TestEdge(), and VectorClampMA().
Calculates the midpoint between two vectors.
[in] | point1 | vector of first point. |
[in] | point2 | vector of second point. |
[out] | midpoint | calculated midpoint vector. |
Definition at line 444 of file mathlib.c.
References f, VectorAdd, and VectorScale.
Calculate a position on v1
v2
line.
[in] | v1 | First point of the line. |
[in] | v2 | Second point of the line. |
[in] | mix | Position on the line. If 0 < mix < 1, out is between v1 and v2 . if mix < 0, out is outside v1 and v2 , on v1 side. |
[out] | out | The resulting point |
Definition at line 419 of file mathlib.c.
References i.
Referenced by FinalLightFace(), GatherSampleLight(), GatherSampleSunlight(), R_FilterTexture(), and S_LoopSample().
Checks whether the given vector v1
is closer to comp
as the vector v2
.
[in] | v1 | Vector to check whether it's closer to comp as v2 |
[in] | v2 | Vector to check against |
[in] | comp | The vector to check the distance from |
v1
is closer to comp
as v2
Definition at line 201 of file mathlib.c.
References VectorLength(), and VectorSubtract.
Referenced by TR_TestLineDist_r(), TR_TestLineDM(), and TR_TileTestLineDM().
Calculate unit vector for a given vec3_t.
[in] | v | Vector to normalize |
< Assign and compare the result
< Assign and use the result
Definition at line 653 of file mathlib.c.
References DotProduct.
Referenced by AddBrushBevels(), AI_CheckFF(), AI_FindHerdLocation(), AIR_GetDestinationWhilePursuing(), BaseWindingForPlane(), BuildFacelights(), BuildLights(), BuildVertexNormals(), CalcLightinfoVectors(), Check_EdgeEdgeIntersection(), CL_ActorVis(), CL_CameraMove(), CL_CameraRoute(), CL_TargetingStraight(), Com_GrenadeTarget(), FixFaceEdges(), FrustumVis(), G_ActorVis(), G_ShootSingle(), GatherSampleLight(), MAP3D_ScreenToMap(), MAP_AngleOfPath2D(), MAP_AngleOfPath3D(), MAP_MapCalcLine(), NudgeSamplePosition(), Orthogonalize(), PerpendicularVector(), PlaneFromPoints(), R_DrawFlareSurfaces(), R_DrawSprite(), R_GetSpriteVectors(), R_InterpolateTransform(), R_ModCalcNormalsAndTangents(), R_ModCalcUniqueNormalsAndTangents(), R_StageTexCoord(), RemoveColinearPoints(), S_SpatializeChannel(), SubdivideFace(), TangentVectors(), and TryMergeWinding().
Calculated the normal vector for a given vec3_t.
[in] | v | Vector to normalize |
[out] | out | The normalized vector |
Definition at line 219 of file mathlib.c.
References DotProduct.
Referenced by CL_CameraMove(), and R_SphereGenerate().
Rotate a vector with a rotation matrix.
[out] | vb | The result of multiplication (ie vector va after rotation). |
[in] | m | The 3*3 matrix (rotation matrix in case of a rotation). |
[in] | va | The vector that should be multiplied (ie rotated in case of rotation). |
m
* va:
this is the same than GLVectorTransform in 3D. This can be used for other applications than rotation. Definition at line 367 of file mathlib.c.
Referenced by Grid_RecalcRouting(), and SV_LinkEdict().
[out] | point | The vector to rotate around and the location of the rotated vector |
[in] | matrix | The input rotation matrix |
Definition at line 534 of file mathlib.c.
References DotProduct, and VectorCopy.
Referenced by R_DrawBrushModel().
const vec4_t color_white |
const float directionAngles[CORE_DIRECTIONS] |
Definition at line 100 of file mathlib.c.
Referenced by CL_ActorAppear(), CL_ActorDoTurn(), G_ActorDoTurn(), LE_DoPathMove(), and UI_RadarNodeDrawActor().
Definition at line 53 of file mathlib.c.
Referenced by CMod_RerouteMap(), Grid_MoveMark(), and RT_UpdateConnectionColumn().
const float dvecsn[CORE_DIRECTIONS][2] |
Definition at line 97 of file mathlib.c.
Referenced by FrustumVis().
Definition at line 103 of file mathlib.c.
Referenced by G_ActorDoTurn().
Definition at line 102 of file mathlib.c.
Referenced by G_ActorDoTurn().
const vec2_t vec2_origin |
Definition at line 32 of file mathlib.c.
Referenced by MAP_GetGeoscapeAngle().
const vec3_t vec3_origin |
Definition at line 33 of file mathlib.c.
Referenced by BaseWindingForNode(), BaseWindingForPlane(), BuildFacelights(), BuildLights(), CalcLightinfoVectors(), CL_ActorVis(), CL_HullForEntity(), CL_ParticleRun2(), CL_TargetingGrenade(), CL_TargetingStraight(), CM_EntTestLine(), CM_EntTestLineDM(), CreateNewFloatPlane(), EmitBrushes(), G_TraceDraw(), LE_PlayFootStepSound(), MakeNodePortal(), ParseBrush(), R_Draw2DMapMarkers(), R_Draw3DMapMarkers(), R_DrawBrushModel(), R_LoadBspVertexArrays(), RT_CheckCell(), RT_GetMapSize(), SV_ClipMoveToEntities(), SV_HullForEntity(), SV_LoadModelMinsMaxs(), SV_PointContents(), SV_Trace(), TR_BoxTrace(), and WindingCenter().
const vec4_t vec4_origin |
Definition at line 34 of file mathlib.c.
Referenced by R_DrawModelDirect(), and R_DrawModelParticle().