TorqueScript Reference

- Main Page
- Related Pages
- Modules
- Classes

Functions
Math (Non-Vector)
Function Categories

## Functions
Integer | addBitToMask (mask, bit)
String | bit ()
String | bitInverse ()
String | bits ()
Float | mAbs (val)
Float | mAcos (val)
Float | mAsin (val)
Float | mAtan (val)
Integer | mCeil (val)
Float | mClamp (float number, float min, float max)
Float | mCos (val)
Float | mDegToRad (val)
String | mFloatLength (val, numDecimals)
Integer | mFloor (val)
Float | mGetMax (a, b)
Float | mGetMin (a, b)
Float | mLog (val)
Float | mPow (val, power)
Float | mRadToDeg (val)
Float | mRound (float v)
Float | mSin (val)
String | mSolveCubic (float a, float b, float c, float d)
String | mSolveQuadratic (float a, float b, float c)
String | mSolveQuartic (float a, float b, float c, float d, float e)
Float | mSqrt (val)
Float | mTan (val)
Integer | removeBitFromMask (mask, bit)

## Detailed Description

## Function Documentation

Integer addBitToMask | ( | mask | ,
|  | bit |
| ) |  |

Returns the mask with a bit added to it

String bit | ( |  | ) |

Converts a bit-position into a value.

String bitInverse | ( |  | ) |

Returns the ones complement of a bit.

String bits | ( |  | ) |

Converts a list of bit-positions into a value.

Float mAbs | ( | val |  | ) |

Use the mAbs function to get the magnitude of val.

Parameters

  val | An integer or a floating-point value.

Returns
  Returns the magnitude of val

Float mAcos | ( | val |  | ) |

Use the mAcos function to get the inverse cosine of val in degrees.

Parameters

  val | A value between -1.0 and 1.0 equal to the cosine of some angle theta.

Returns
  Returns the inverse cosine of val in radians. This value will be in the range [ 0 , 180 ].

See also
  mCos

Float mAsin | ( | val |  | ) |

Use the mAsin function to get the inverse sine of val in degrees.

Parameters

  val | A value between -1.0 and 1.0 equal to the sine of some angle theta.

Returns
  Returns the inverse sine of val in degrees. This value will be in the range [ -90, 90 ].

See also
  mSin

Float mAtan | ( | val |  | ) |

Use the mAtan function to get the inverse tangent of rise/run in degrees. May be called as mAtan( deltaX, deltaY ) or mAtan( "deltaX deltaY" ).

Parameters

  x-axis | run Horizontal component of a line.
  y-axis | rise Vertical component of a line.

Returns
  Returns the slope in degrees (the arc-tangent) of a line with the given run and rise.

See also
  mTan

Integer mCeil | ( | val |  | ) |

Use the mCeil function to calculate the next highest integer value from val.

Parameters

  val | A floating-point value.

Returns
  Returns an integer representing the next highest integer from val.

See also
  mFloor

Float mClamp | ( | float | number,
|  | float | min,
|  | float | max
| ) |  |

Clamp a value between two other values.

Parameters

  number | A float value representing the number to clamp
  min | The lower bound
  max | The upper bound

Returns
  A float value the is within the given range

Float mCos | ( | val |  | ) |

Use the mCos function to get the cosine of the angle val.

Parameters

  val | A value in degrees.

Returns
  Returns the cosine of val. This value will be in the range [ -1.0 , 1.0 ].

See also
  mAcos

Float mDegToRad | ( | val |  | ) |

Use the mDegToRad function to convert degrees to radians.

Parameters

  val | A floating-point number representing some number of degrees.

Returns
  Returns the equivalent of the degree value val in radians.

See also
  mRadToDeg

String mFloatLength | ( | val | ,
|  | numDecimals |
| ) |  |

Use the mFloatLength function to limit the number of decimal places in val to numDecimals.

Parameters

  val | A floating-point value.
  numDecimals | An integer between 0 and inf representing the number of decimal places to allow val to have.

Returns
  Returns a floating-point value equivalent to a truncated version of val, where the new version has numDecimals decimal places

Integer mFloor | ( | val |  | ) |

Use the mFloor function to calculate the next lowest integer value from val.

Parameters

  val | A floating-point value.

Returns
  Returns an integer representing the next lowest integer from val.

See also
  mCeil

Float mGetMax | ( | a | ,
|  | b |
| ) |  |

Returns the Maximum of two values.

Float mGetMin | ( | a | ,
|  | b |
| ) |  |

Returns the Minimum of two values.

Float mLog | ( | val |  | ) |

Use the mLog function to calculate the natural logarithm of val.

Parameters

  val | A numeric value.

Returns
  Returns the natural logarithm of val

Float mPow | ( | val | ,
|  | power |
| ) |  |

Use the mPow function to calculated val raised to the power of power.

Parameters

  val | A numeric (integer or floating-point) value to be raised to a power.
  power | A numeric (integer or floating-point) power to raise val to.

Returns
  Returns val^power

Float mRadToDeg | ( | val |  | ) |

Use the mRadToDeg function to convert radians to degrees.

Parameters

  val | A floating-point number representing some number of radians.

Returns
  Returns the equivalent of the radian value val in degrees.

See also
  mDegToRad

Float mRound | ( | float | v | ) |

Rounds a number. 0.5 is rounded up.

Parameters

  val | A floating-point value

Returns
  Returns the integer value closest to the given float

Float mSin | ( | val |  | ) |

Use the mSin function to get the sine of the angle val.

Parameters

  val | A value in degrees.

Returns
  Returns the sine of val. This value will be in the range [ -1.0 , 1.0 ].

See also
  mAsin

String mSolveCubic | ( | float | a,
|  | float | b,
|  | float | c,
|  | float | d
| ) |  |

Solve a cubic equation of form a*x^3 + b*x^2 + c*x + d = 0.

Returns
  A 4-tuple, contanining: sol x0 x1 x2. sol is the number of solutions (being 0, 1, 2, or 3), and x0, x1, x2 are the solutions, if any. Unused x's are undefined.

String mSolveQuadratic | ( | float | a,
|  | float | b,
|  | float | c
| ) |  |

Solve a quadratic equation of form a*x^2 + b*x + c = 0.

Returns
  A triple, contanining: sol x0 x1. sol is the number of solutions (being 0, 1, or 2), and x0 and x1 are the solutions, if any. Unused x's are undefined.

String mSolveQuartic | ( | float | a,
|  | float | b,
|  | float | c,
|  | float | d,
|  | float | e
| ) |  |

Solve a quartic equation of form a*x^4 + b*x^3 + c*x^2 + d*x + e = 0.

Returns
  A 5-tuple, contanining: sol x0 x1 x2 x3. sol is the number of solutions (ranging from 0-4), and x0, x1, x2 and x3 are the solutions, if any. Unused x's are undefined.

Float mSqrt | ( | val |  | ) |

Use the mSqrt function to calculated the square root of val.

Parameters

  val | A numeric value.

Returns
  Returns the the squareroot of val

Float mTan | ( | val |  | ) |

Use the mTan function to get the tangent of the angle val.

Parameters

  val | A value in degrees.

Returns
  Returns the tangent of val. This value will be in the range [ -inf.0 , inf.0 ].

See also
  mAtan

Integer removeBitFromMask | ( | mask | ,
|  | bit |
| ) |  |

Returns the mask with a bit removed from it