Skip to content

Mathf

The Mathf class is a collection of commonly used mathematical functions.

静态变量

Mathf.pi : number
π
Mathf.half_pi : number
π/2
Mathf.double_pi : number
Mathf.radToAngle : number
180/π
Mathf.inv_pi : number
1/π
Mathf.angleToRad : number
π/180
Mathf.inv_pi_double : number
1/(2π)
Mathf.eps : number
1e-5
Mathf.sqrEps : number
1e-8
Mathf.ln2 : number
ln2
Mathf.ln2sqrt : number
√ln2

静态方法

Mathf.Sqrt ( val : number ) : number
Calculates the square root of a given value.
Mathf.Sin ( rad : number ) : number
Returns the sine value of the angle in radians.
Mathf.Pow ( f : number , p : number ) : number
Returns the value of f raised to the power of p.
Mathf.FloorToInt ( value : number ) : number
Returns the largest integer less than or equal to the specified value.
Mathf.Max ( lhs : number , rhs : number ) : number
Returns the maximum value among two or more values.
Mathf.Clamp ( val : number , left : number , right : number ) : number
Limits the given value to be within the given minimum float value and maximum float value. If the given value is within the minimum and maximum range, it returns the given value.
Mathf.CeilToInt ( value : number ) : number
Returns the smallest integer greater than or equal to the specified value.
Mathf.Lerp ( left : number , right : number , t : number ) : number
Performs a linear interpolation between the left and right values using the specified value.
Mathf.Min ( lhs : number , rhs : number ) : number
Returns the minimum value among two or more values.
Mathf.LerpUnclamped ( left : number , right : number , t : number ) : number
Linearly interpolates between the left and right values using t, with no restriction on t.
Mathf.ACos ( val : number ) : number
Returns the arc cosine (in radians) of val, where val is the cosine value.
Mathf.Cos ( rad : number ) : number
Returns the cosine value of the angle in radians.
Mathf.ASin ( val : number ) : number
Returns the arc sine (in radians) of the specified value val.
Mathf.Tan ( rad : number ) : number
Returns the tangent value of the angle in radians.
Mathf.Exp ( val : number ) : number
Returns the specified power of e.
Mathf.ATan2 ( y : number , x : number ) : number
Returns the angle (in radians) from the X-axis to a point.
Mathf.Floor ( val : number ) : number
Returns the largest integer less than or equal to flr.
Mathf.Round ( val : number ) : number
Returns the value of the specified number rounded to the nearest integer.
Mathf.Sign ( val : number ) : number
Returns the sign (positive/negative) of v.
Mathf.Log ( val : number , new_base : number? ) : number
Returns the logarithm of a specified value in a specified base.
Mathf.Log10 ( val : number ) : number
Returns the logarithm of x to the base 10.