math primitives More...
#include "../common/common.h"
Go to the source code of this file.
Defines | |
#define | logf(x) ((float)log((double)(x))) |
#define | RT2 0.70710678118654752440084436210485 |
cos 45 degree | |
Functions | |
int | AngleToDir (int angle) |
Returns the indice of array directionAngles[DIRECTIONS] whose value is the closest to angle. | |
vec_t | Q_rint (const vec_t in) |
Round to nearest integer. | |
float | GetDistanceOnGlobe (const vec2_t pos1, const vec2_t pos2) |
Calculate distance on the geoscape. | |
vec_t | ColorNormalize (const vec3_t in, vec3_t out) |
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 | VectorNormalize2 (const vec3_t v, vec3_t out) |
Calculated the normal vector for a given vec3_t. | |
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 | 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. | |
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. | |
vec_t | VectorLength (const vec3_t v) |
Calculate the length of a vector. | |
void | VectorMix (const vec3_t v1, const vec3_t v2, float mix, vec3_t out) |
Calculate a position on v1 v2 line. | |
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. | |
float | VectorAngleBetween (const vec3_t vec1, const vec3_t vec2) |
Calculates the angle (in radians) between the two given vectors. | |
int | Q_log2 (int val) |
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 | |
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. | |
qboolean | FrustumVis (const vec3_t origin, int dir, const vec3_t point) |
Checks whether a point is visible from a given position. | |
static void | ProjectPointOnPlane (vec3_t dst, const vec3_t point, const vec3_t normal) |
Projects a point on a plane passing through the origin. | |
vec_t | VectorNormalize (vec3_t v) |
Calculate unit vector for a given vec3_t. | |
void | PerpendicularVector (vec3_t dst, const vec3_t src) |
Finds a vector perpendicular to the source vector. | |
void | CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross) |
binary operation on vectors in a three-dimensional space | |
static void | R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]) |
void | RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees) |
Rotate a point around a given vector. | |
void | Print3Vector (const vec3_t v) |
Print a 3D vector. | |
void | Print2Vector (const vec2_t v) |
Print a 2D vector. | |
void | PolarToVec (const vec2_t a, vec3_t v) |
Converts longitude and latitude to a 3D vector in Euclidean coordinates. | |
void | VecToPolar (const vec3_t v, vec2_t a) |
Converts vector coordinates into polar coordinates. | |
void | VecToAngles (const vec3_t value1, vec3_t angles) |
Converts a vector to an angle vector. | |
qboolean | Q_IsPowerOfTwo (int i) |
Checks whether i is power of two value. | |
float | LerpAngle (float a2, float a1, float frac) |
Returns the angle resulting from turning fraction * angle from angle1 to angle2. | |
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] | |
void | VectorCenterFromMinsMaxs (const vec3_t mins, const vec3_t maxs, vec3_t center) |
Calculates the center of a bounding box. | |
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. | |
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 = { 0, 0 } |
const vec3_t | vec3_origin = { 0, 0, 0 } |
const vec4_t | vec4_origin = { 0, 0, 0, 0 } |
const vec4_t | dvecs [PATHFINDING_DIRECTIONS] |
const float | dvecsn [CORE_DIRECTIONS][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}, {RT2, RT2}, {-RT2, -RT2}, {-RT2, RT2}, {RT2, -RT2} } |
const float | directionAngles [CORE_DIRECTIONS] = { 0, 180.0f, 90.0f, 270.0f, 45.0f, 225.0f, 135.0f, 315.0f } |
const byte | dvright [CORE_DIRECTIONS] = { 7, 6, 4, 5, 0, 1, 2, 3 } |
const byte | dvleft [CORE_DIRECTIONS] = { 4, 5, 6, 7, 2, 3, 1, 0 } |
math primitives
Definition in file mathlib.c.
#define logf | ( | x | ) | ((float)log((double)(x))) |
Definition at line 29 of file mathlib.c.
Referenced by gaussrand().
#define RT2 0.70710678118654752440084436210485 |
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 | a2, | |
float | a1, | |||
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().
static void ProjectPointOnPlane | ( | vec3_t | dst, | |
const vec3_t | point, | |||
const vec3_t | normal | |||
) | [inline, static] |
Projects a point on a plane passing through the origin.
[in] | point | Coordinates of the point to project |
[in] | normal | The normal vector of the plane |
[out] | dst | Coordinates of the projection on the plane |
Non-null
pointers and a normalized normal vector. < closest distance from the point to the plane
Definition at line 623 of file mathlib.c.
References DotProduct.
Referenced by PerpendicularVector().
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().
static void R_ConcatRotations | ( | float | in1[3][3], | |
float | in2[3][3], | |||
float | out[3][3] | |||
) | [inline, static] |
Definition at line 726 of file mathlib.c.
Referenced by RotatePointAroundVector().
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 float directionAngles[CORE_DIRECTIONS] = { 0, 180.0f, 90.0f, 270.0f, 45.0f, 225.0f, 135.0f, 315.0f } |
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] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}, {RT2, RT2}, {-RT2, -RT2}, {-RT2, RT2}, {RT2, -RT2} } |
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 = { 0, 0 } |
Definition at line 32 of file mathlib.c.
Referenced by MAP_GetGeoscapeAngle().
const vec3_t vec3_origin = { 0, 0, 0 } |
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 = { 0, 0, 0, 0 } |
Definition at line 34 of file mathlib.c.
Referenced by R_DrawModelDirect(), and R_DrawModelParticle().