TorqueScript Reference
Functions

Functions

String VectorAdd (vecA, vecB)
 
String VectorCross (vecA, vecB)
 
Float VectorDist (vecA, vecB)
 
Float VectorDot (vecA, vecB)
 
Float VectorLen (vec)
 
String VectorNormalize (vec)
 
String VectorOrthoBasis (vec)
 
String VectorScale (vec, scale)
 
String VectorSub (vecA, vecB)
 

Detailed Description

‍/

<functions, functions, functions!>

/*!

Function Documentation

◆ VectorAdd()

String VectorAdd ( vecA  ,
vecB   
)

Use the VectorAdd function to add two vectors of up to three elements each to each other

Parameters
vecAA vector of up to three elements.
vecBA vector of up to three elements.
Returns
Returns the result of vecA + vecB.
See also
vectorSub

◆ VectorCross()

String VectorCross ( vecA  ,
vecB   
)

Use the VectorCross function to calculate the cross product of two vectors of up to three elements each. Remember, the resultant vector will always be an right angles (orthogonal) to both input vectors.

Parameters
vecAA vector of up to three elements.
vecBA vector of up to three elements.
Returns
Returns the result of vecA x vecB.
See also
VectorDot

◆ VectorDist()

Float VectorDist ( vecA  ,
vecB   
)

Use the VectorDist function to calculate distance between two vectors of up to three elements each.

Parameters
vecAA vector of up to three elements.
vecBA vector of up to three elements.
Returns
Returns the result of \ |Xa - Xb| |Ya - Yb| |Za - Zb| .
See also
VectorLen

◆ VectorDot()

Float VectorDot ( vecA  ,
vecB   
)

Use the VectorCross function to calculate the dot product of two unit vectors of up to three elements each. Warning! Be sure to always normalize both vecA and vecB before attempting to find the dot product. Calculating a dot product using un-normalized vectors (non- unit vectors) will result in meaningless results. If the return value is < 0, the inner-angle between the vectors is > 90 degrees. If the return value is == 0, the inner-angle between the vectors is == 90 degrees. If the return value is > 0, the inner-angle between the vectors is < 90 degrees.

Parameters
vecAA unit-vector of up to three elements.
vecBA unit-vector of up to three elements.
Returns
Returns a scalar value equal to the result of vecA . vecB. This value which will always be a single floating-point value in the range [ -1 , +1 ].
See also
VectorCross

◆ VectorLen()

Float VectorLen ( vec  )

Use the VectorLen function to calculate the length of vector vec.

Parameters
vecA vector of up to three elements.
Returns
Returns a scalar representing the length of the vector vec.
See also
VectorDist

◆ VectorNormalize()

String VectorNormalize ( vec  )

Use the VectorNormalize function to calculated the unit vector equivalent of the vector vec.

Parameters
vecA vector of up to three elements.
Returns
Returns the unit vector equivalent of the vector vec.
See also
VectorScale

◆ VectorOrthoBasis()

String VectorOrthoBasis ( vec  )

Use the VectorOrthoBasis function to calculate a 3x3 Row-Major formated matrix representing the orthogonal basis for the vector vec.

Parameters
vecA four element vector of the form \AxisX AxisY AxisZ theta\, where theta is the angle of rotation about the vector formed by the prior three values.
Returns
Returns a 3x3 Row-Major formated matrix

◆ VectorScale()

String VectorScale ( vec  ,
scale   
)

Use the VectorScale function to scale the vector vec by the scalar scale.

Parameters
vecA vector of up to three elements.
scaleA numeric value (integer or floating-point) representing the scaling factor.
Returns
Returns a scaled version of the vector vec, equivalent to: ( scale * X ) ( scale * Y ) ( scale * Z ).
See also
VectorNormalize

◆ VectorSub()

String VectorSub ( vecA  ,
vecB   
)

Use the VectorSub function to subtract vecB from vecA.

Parameters
vecALeft side vector in subtraction equation.
vecBRight side vector in subtraction equation.
Returns
Returns a new vector equivalent to: \vecA - vecB.
See also
vectorAdd