Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Math Class Reference

General Math functions. More...

Public Member Functions

decimal Cos (decimal x)
 Returns the cosine of an angle of x radians.
decimal Sin (decimal x)
 Returns the sine of an angle of x radians.
decimal Tan (decimal x)
 Returns the tangent of an angle of x radians.
decimal Acos (decimal x)
 Returns the arccosine of x.
decimal Asin (decimal x)
 Returns the arcsine of x.
decimal Atan (decimal x, decimal y)
 Returns the arctangent angle (in radians) from x and y.
decimal Distance (number x1, number y1, number x2, number y2)
 Gets the distance from (x1,y1) to (x2,y2) in pixels.
decimal Direction (number x1, number y1, number x2, number y2)
 Gets the angle from (x1,y1) to (x2,y2) in radians.
number Abs (number n)
 Gets the absolute value of a Number.
number Min (number a, number b)
 Gets the lesser value of two Number values.
number Max (number a, number b)
 Gets the greater value of two Number values.
number Clamp (number n, number minValue, number maxValue)
 Gets the value clamped between a range.
decimal Sign (number n)
 Gets the sign associated with a decimal value.
integer Uint8 (integer n)
 Converts an integer to an 8-bit unsigned value.
integer Uint16 (integer n)
 Converts an integer to a 16-bit unsigned value.
integer Uint32 (integer n)
 Converts an integer to a 32-bit unsigned value.
integer Uint64 (integer n)
 Converts an integer to a 64-bit unsigned value.
decimal Random ()
 Get a random number between 0.0 and 1.0.
decimal RandomMax (number max)
 Gets a random number between 0.0 and a specified maximum.
decimal RandomRange (number min, number max)
 Gets a random number between specified minimum and a specified maximum.
integer Floor (number n)
 Rounds the number n downward, returning the largest integral value that is not greater than n.
decimal Ceil (number n)
 Rounds the number n upward, returning the smallest integral value that is not less than n.
decimal Round (number n)
 Rounds the number n.
decimal Sqrt (number n)
 Retrieves the square root of the number n.
decimal Pow (number n, number p)
 Retrieves the number n to the power of p.
decimal Exp (number p)
 Retrieves the constant e (2.717) to the power of p.

Detailed Description

General Math functions.

Member Function Documentation

◆ Abs()

number Math.Abs ( number n)

Gets the absolute value of a Number.

Parameters
nNumber value.
Returns
Returns the absolute value of n.

◆ Acos()

decimal Math.Acos ( decimal x)

Returns the arccosine of x.

Parameters
xNumber value to get the arccosine of.
Returns
Returns the angle (in radians) as a decimal value.

◆ Asin()

decimal Math.Asin ( decimal x)

Returns the arcsine of x.

Parameters
xNumber value to get the arcsine of.
Returns
Returns the angle (in radians) as a decimal value.

◆ Atan()

decimal Math.Atan ( decimal x,
decimal y )

Returns the arctangent angle (in radians) from x and y.

Parameters
xx value.
yy value.
Returns
The angle from x and y.

◆ Ceil()

decimal Math.Ceil ( number n)

Rounds the number n upward, returning the smallest integral value that is not less than n.

Parameters
nNumber to be rounded.
Returns
Returns the ceiling-ed number value.

◆ Clamp()

number Math.Clamp ( number n,
number minValue,
number maxValue )

Gets the value clamped between a range.

Parameters
nNumber value.
minValueMinimum range value to clamp to.
maxValueMaximum range value to clamp to.
Returns
Returns the Number value if within the range, otherwise returns closest range value.

◆ Cos()

decimal Math.Cos ( decimal x)

Returns the cosine of an angle of x radians.

Parameters
xAngle (in radians) to get the cosine of.
Returns
The cosine of x radians.

◆ Direction()

decimal Math.Direction ( number x1,
number y1,
number x2,
number y2 )

Gets the angle from (x1,y1) to (x2,y2) in radians.

Parameters
x1X position of first point.
y1Y position of first point.
x2X position of second point.
y2Y position of second point.
Returns
Returns the angle from (x1,y1) to (x2,y2) as a decimal value.

◆ Distance()

decimal Math.Distance ( number x1,
number y1,
number x2,
number y2 )

Gets the distance from (x1,y1) to (x2,y2) in pixels.

Parameters
x1X position of first point.
y1Y position of first point.
x2X position of second point.
y2Y position of second point.
Returns
Returns the distance from (x1,y1) to (x2,y2) as a decimal value.

◆ Exp()

decimal Math.Exp ( number p)

Retrieves the constant e (2.717) to the power of p.

Parameters
pExponent.
Returns
Returns the result number.

◆ Floor()

integer Math.Floor ( number n)

Rounds the number n downward, returning the largest integral value that is not greater than n.

Parameters
nNumber to be rounded.
Returns
Returns the floored number value.

◆ Max()

number Math.Max ( number a,
number b )

Gets the greater value of two Number values.

Parameters
aNumber value.
bNumber value.
Returns
Returns the greater value of a and b.

◆ Min()

number Math.Min ( number a,
number b )

Gets the lesser value of two Number values.

Parameters
aNumber value.
bNumber value.
Returns
Returns the lesser value of a and b.

◆ Pow()

decimal Math.Pow ( number n,
number p )

Retrieves the number n to the power of p.

Parameters
nNumber for the base of the exponent.
pExponent.
Returns
Returns the number n to the power of p.

◆ Random()

decimal Math.Random ( )

Get a random number between 0.0 and 1.0.

Returns
Returns the random number.

◆ RandomMax()

decimal Math.RandomMax ( number max)

Gets a random number between 0.0 and a specified maximum.

Parameters
maxMaximum non-inclusive value.
Returns
Returns the random number.

◆ RandomRange()

decimal Math.RandomRange ( number min,
number max )

Gets a random number between specified minimum and a specified maximum.

Parameters
minMinimum non-inclusive value.
maxMaximum non-inclusive value.
Returns
Returns the random number.

◆ Round()

decimal Math.Round ( number n)

Rounds the number n.

Parameters
nNumber to be rounded.
Returns
Returns the rounded number value.

◆ Sign()

decimal Math.Sign ( number n)

Gets the sign associated with a decimal value.

Parameters
nNumber value.
Returns
Returns -1 if n is negative, 1 if positive, and 0 if otherwise.

◆ Sin()

decimal Math.Sin ( decimal x)

Returns the sine of an angle of x radians.

Parameters
xAngle (in radians) to get the sine of.
Returns
The sine of x radians.

◆ Sqrt()

decimal Math.Sqrt ( number n)

Retrieves the square root of the number n.

Parameters
nNumber to be square rooted.
Returns
Returns the square root of the number n.

◆ Tan()

decimal Math.Tan ( decimal x)

Returns the tangent of an angle of x radians.

Parameters
xAngle (in radians) to get the tangent of.
Returns
The tangent of x radians.

◆ Uint16()

integer Math.Uint16 ( integer n)

Converts an integer to a 16-bit unsigned value.

Parameters
nInteger value to convert.
Returns
Returns the converted value.

◆ Uint32()

integer Math.Uint32 ( integer n)

Converts an integer to a 32-bit unsigned value.

Parameters
nInteger value to convert.
Returns
Returns the converted value.

◆ Uint64()

integer Math.Uint64 ( integer n)

Converts an integer to a 64-bit unsigned value.

Parameters
nInteger value to convert.
Returns
Returns the converted value.

◆ Uint8()

integer Math.Uint8 ( integer n)

Converts an integer to an 8-bit unsigned value.

Parameters
nInteger value to convert.
Returns
Returns the converted value.