
NOTE : Underscores
Some of the functions are given as two versions, those with a leading underscore and those
without. Those with the underscore are actual functions. Those without are macros #defined
in q_shared.h. I believe that the #defined versions are more efficient (may be no difference,
depends on compiler?). In general you should use the versions without the underscore.
NOTE : Format of Quake2 variables
vector - represented by type vec3_t, basically an array of floats, with :
vector[0] = x coordinate
vector[1] = y coordinate
vector[2] = z coordinate
angles - also represented by type vec3_t, this time with:
angles[0] = pitch (up and down)
angles[1] = yaw (turn left and right)
angles[2] = roll (tilt left and right, not really used)
angle - represented by a float
Angles
anglemod (angle)
returns the equivalent of angle between 0 and 360 degrees
LerpAngle (angle1, angle2, fraction)
returns the angle resulting from turning fraction * angle from angle1 to angle2
(and if you can't make sense of that, don't worry, this isn't actually used anywhere)
Bounding Box
AddPointToBounds (point, mins, maxs)
if the point is outside the box defined by mins and maxs, expand the box to accomodate it.
sets mins and maxs to their new values
ClearBounds (mins, maxs)
sets mins and maxs to starting points before using AddPointToBounds
Floats
Q_fabs (number)
if the number is < 0, returns -1 * number, otherwise returns the number
Q_log2 (number)
returns the log to base 2 of the number
Info strings
Info_RemoveKey (string, key)
searches through string for key, then removes it
Info_SetValueForKey (string, key, value)
adds a new entry 'key' into string with value 'value'. removes any old versions of key.
NOTE : value should be a string
Info_ValueForKey (string, key)
searches through string for key, then retunrs the value associated with key
Strings
Q_strcasecmp (string1, string2)
compares string1 and string2, returning 0 if they are the same
NOTE : ignores case
Q_stricmp (string1, string2)
compares the two strings, returning 0 if they are identical
NOTE : case must be identical
Q_strncasecmp (string1, string2, number)
compares the first 'number' letters in string1 and string2, returning 0 if they are the same
NOTE : ignores case
Vectors
AngleVectors (angles, forward_vector, right_vector, up_vector)
Converts the angles into various vectors :
forward_vector : vector along angles
right_vector : vector 90 degrees to the right of forward_vector
up_vector : vector 90 up from forward_vector
CrossProduct (vector1, vector2, vector_out)
sets vector_out to the cross product of vector1 and vector2
NOTE on cross product :
This gives a vector perpendicular to vector1 and vector2, of length :
'length vector1' * 'length vector2' * sin (angle from vector1 to vector2)
If you want to know how it's calculated, look at the code in q_shared.c
DotProduct (vector1, vector2), _DotProduct (vector1, vector2)
gives the dot product of vector1 and vector2
NOTE on dot product :
This is calculated by vector1[0]*vector2[0] + vector1[1]*vector2[1] + vector1[2] * vector2[2]
It is also equal to 'length of vector1' * 'length of vector2' * cos (angle between vectors)
vectoangles (vector, angles)
Sets the angles array to point in the same direction as the vector
VectorAdd (vector1,vector2,vector_out), _VectorAdd (vector1,vector2,vector_out)
adds vector1 to vector2 and puts the result in vector_out
VectorClear (vector)
sets the vector to <0,0,0>
VectorCompare (vector1, vector2)
returns 1 if the vectors are the same and 0 otherwise
VectorCopy (vector_in,vector_out), _VectorCopy (vector_in,vector_out)
copies vector_in to vector_out
VectorInverse (vector)
sets vector to -1 * vector
VectorLength (vector)
returns the length of the vector
VectorMA (vector1, scale, vector2, vector_out)
sets vector_out to : vector1 + scale * vector2
VectorNegate (vector_in, vector_out)
sets vector_out to -1 * vector_in
VectorNormalize (vector)
returns a vector in the same direction as the given vector, but only one unit long
VectorNormalize2 (vector_in, vector_out)
sets vector_out to the normalised version of vector_in. returns the length of vector_in
VectorScale (vector_in, scale, vector_out)
sets vector_out to scale * vector_in
VectorSet (vector, x, y, z)
sets the x coordinate of vector to x, the y coordinate to y, etc.
VectorSubtract (vector1,vector2,vector_out), _VectorSubtract (vector1,vector2,vector_out)
subtracts vector2 from vector1 and puts the result in vector_out
vectoyaw (vector)
Returns the yaw component of the angles vector
vtos (vector)
converts a vector into a string
Returns the string