#include "maps/global_scripts/global_common.scr"
These are a general set of math functions that can be used
Refer to each functions description
float globalMath_NormalizeAngleTo360Degrees( degrees )
Purpose:
Takes any degreeangle and forces it into the range [0,360]. The new
angle value is returned.
Returns:
Float. The new normalized angle results.
Parms:
 degrees  (float)
T he angle to normalize to the range [0,360]
float globalMath_GetCircularDistanceInDegrees( degreeAngle1,
degreeAngle2 )
Purpose:
Returns the distance from one point on a circle to another point on
that same circle, given in degrees.
Returns:
Float. The radial distance in degrees one point is from another. If
the return value is positive, the closest path is counterclockwise,
else if it's negative, it is clockwise.
Parms:
 degreeAngle1 (float)
The angle, in degrees, of the starting point.
 degreeAngle2 (float)
The angle, in degrees, of the ending point.
float globalMath_GetXYAngleForPointAboutCenter( point, center
)
Purpose:
Takes the center origin of a circle, and an orbiting point on the circle,
and calculates the angle in degrees where the oribiting point is located.
0 degrees being due East.
Returns:
float, the angle in degrees where the oribiting point is on the circle
relative to the passed center coordinate vector. For reference, the
4 main points are:
 0  East
 90  North
 180  West
 270  South
Parms:
 point (vector)
The xyz location of the oribiting point.
 center (vector)
The xyz location of the origin.
vector globalMath_RotateAnglesInXYPlane( inputAngles, degrees
)
Purpose:
Takes the passed in angles facing and rotates the Y axis the desired
number
of degrees.
Returns:
Vector. The new angles after the Y axis rotation has been applied.
Parms:
 inputAngles (vector)
The starting angles to rotate.
 degrees (float)
The number of degrees to rotate the Y axis.
vector globalMath_RotatePointInXYPlane( inputPoint, pivotPoint,
degrees )
Purpose:
Takes the passed in point and pivots it around a passed in pivot point
in the XY plane.
Returns:
vector, the new origin of the pivoted point.
Parms:
 inputPoint (vector)
The point to pivot,
 pivotPoint (vector)
The point to pivot around
 degrees (float)
The number of degrees to pivot the point.
vector globalMath_MirrorAnglesInXYPlane( vector inputAngles,
float degrees )
Purpose:
Takes the passed in angles facing and mirrors them in the XY plane.
The mirroring line is determined by the passed in degrees. The main
points are:
 0  East / West
 90  North South
 180  East / West
 270  North / South
Anything above 179 degrees is redundant as in the actual direction
of the line is irrelevant for this calculation.
Returns:
Vector; the new mirrored angles facing.
Parms:
 inputAngles (vector)
The starting angles to mirror.
 degrees (float)
Determines how to place the mirroring line.
vector globalMath_MirrorPointInXYPlane( inputPoint, pivotPoint,
degrees )
Purpose:
Takes the passed in point and mirrors it in the XY plane. The mirroring
line is determined by the passed in degrees. The main points are:
 0  East / West
 90  North South
 180  East / West
 270  North / South
Anything above 179 degrees is redundant as in the actual direction
of the line is irrelevant for this calculation.
The pivot point is used to determine where to place the mirror in the
world. So the mirroring line will be drawn through the pivot point,
and it's relative location to the point to be mirrored will be taken
into account.
Returns:
vector, the new origin of the mirrored point.
Parms:
 inputPoint (vector)
The point to mirror
.
 pivotPoint (vector)
The point to mirror around.
 degrees (float)
Determines how to place the mirroring line.
float globalMath_GetDistance( vecFrom, vecTo )
Purpose:
Calculates the distance in units between two given coordinates in 3
dimensions.
Returns:
Float. The distance in units between the two passed in coordinate points.
Parms:
 vecFrom (vector)
The xyz location of the starting point.
 vecTo (vector)
The xyz location of the ending point.
float globalMath_GetXYDistance( vecFrom, vecTo )
Purpose:
Calculates the distance in units between two given points only taking
the X and Y coordinates into account. So it's returning a straightline
distance from a topdown (XY) only perspective (2 dimensions).
Returns:
Float, the distance in units between the two passed in coordinate points.
Parms:
 vecFrom (vector)
The xyz location of the starting point.
 vecTo (vector),
The xyz location of the ending point.
float globalMath_RampUp_GetMovementPercentage( float fltPercentageDone_Move
)
Purpose:
Based on a set Sin curve, takes the passed in percentage and converts
it to a percentage based on a ramping up acceleration curve.
Returns:
Float. The equivalent percentage value taking acceleration into account.
Parms:
 fltPercentageDone_Move (float)
The percentage to convert, from 0  1.
float globalMath_RampDown_GetMovementPercentage( float fltPercentageDone_Move
)
Purpose:
Based on a set Sin curve, takes the passed in percentage and converts
it to a
percentage based on a ramping down acceleration curve.
Returns:
Float. The equivalent percentage value taking acceleration into account.
Parms:
 fltPercentageDone_Move (float)
The percentage to convert, from 0  1.
float globalMath_RampUpDown_GetMovementPercentage( float fltPercentageDone_Move
)
Purpose:
Based on a set Sin curve, takes the passed in percentage and converts
it to a percentage based on a ramping up, then back down acceleration
curve.
Returns:
Float. The equivalent percentage value taking acceleration into account
Parms:
 fltPercentageDone_Move (float)
The percentage to convert, passed value from 0  1.
vector globalMath_LerpGetPosition( vector vecMove, float fltPercentageDone_Distance
)
Purpose:
Takes the passed in vector, and using that vector as the ending point
in a line going from '0 0 0', returns a percentage of that distance.
Returns:
Vector. The converted value based on the passed percentage.
Parms:
 vecMove (vector)
The value to consider as the ending point in a line from '0 0 0' for
the conversion.
 fltPercentageDone_Distance (float)
The percentage of vecMove to return. Passed value from 0  1.
float globalMath_LinearFalloff ( maxDistance, maxValue, _origin
, location )
Purpose:
Provides a linear falloff from 0 to maxValue, based on the distance
of location from origin, up to a maxDistance. Once maxDistance is exceeded,
the value is clamped to maxValue.
Returns:
Float. A value from 0 to maxValue, based on the distance of location
from _origin, clamped to maxValue at maxDistance and greater.
Parms:
 maxDistance (float)
maxDistance  Maximum distance to use for interpolation. Any distance
past maxDistance returns maxValue.
 maxValue (float)
Maximum allowed value, corresponds to being at exactly maxDistance from
the origin.
 _origin (vector)
Center of the distance test.
 location (vector)
Location of the value being tested in space. Used to calculate a distance
from _origin.
