Class: MathUtil
Defined in: src/math/MathUtil.ts:44
Built-in mathematical basic calculation factory function
Constructors
Constructor
new MathUtil():
MathUtil
Returns
MathUtil
Methods
clampf()
staticclampf(value,min_inclusive,max_inclusive):number
Defined in: src/math/MathUtil.ts:107
Limit the value to a certain range
Parameters
value
number
Original value
min_inclusive
number
minimum value
max_inclusive
number
maximum value
Returns
number
Return the calculation result
normalizeAngle()
staticnormalizeAngle(a):number
Defined in: src/math/MathUtil.ts:121
Normalize the Angle so that it is limited to the range [-180, 180]
Parameters
a
number
Angle of input
Returns
number
Return the processing result
fract()
staticfract(v):number
Defined in: src/math/MathUtil.ts:136
Returns the fractional part of a number
Parameters
v
number
input value
Returns
number
Return the result
getRandDirXZ()
staticgetRandDirXZ(r):object
Defined in: src/math/MathUtil.ts:145
Generate a random pair of x and z coordinates that fall within the radius of the circle
Parameters
r
number
radius
Returns
object
The generated x, z results
x
x:
number
z
z:
number
getRandDirXYZ()
staticgetRandDirXYZ(r):Vector3
Defined in: src/math/MathUtil.ts:158
Generate a random pair of x, y, and z coordinates that fall within the radius of the sphere
Parameters
r
number
radius
Returns
The Vector3 vector formed by the generated x, y, and z coordinate values
getCycleXYZ()
staticgetCycleXYZ(r):Vector3
Defined in: src/math/MathUtil.ts:172
According to the radius, generate a random pair of x, y, z coordinates that fall within the sphere and the y value is between [-r/2, r/2]
Parameters
r
number
radius
Returns
The Vector3 vector formed by the generated x, y, and z coordinate values
angle()
staticangle(p1,p2):number
Defined in: src/math/MathUtil.ts:187
Calculate the Angle between two vectors
Parameters
p1
Vector 1
p2
Vector 2
Returns
number
Return the calculation result
angle_360()
staticangle_360(from,to):number
Defined in: src/math/MathUtil.ts:203
Calculate the Angle between two vectors
Parameters
from
Vector 1
to
Vector 2
Returns
number
The Angle between two vectors
fromToRotation()
staticfromToRotation(fromDirection,toDirection,target?):Quaternion
Defined in: src/math/MathUtil.ts:231
Calculate the quaternion from one direction to the other
Parameters
fromDirection
Initial direction
toDirection
The transformed direction
target?
Quaternion = null
The calculated quaternion is null by default and the result is returned
Returns
Quaternion The calculated quaternion returns a new instance created if target is null
getEularDir_yUp()
staticgetEularDir_yUp(v):Vector3
Defined in: src/math/MathUtil.ts:244
Get the Eular direction
Parameters
v
number
input value
Returns
Return the calculation result
transformVector()
statictransformVector(matrix,vector,result?):Vector3
Defined in: src/math/MathUtil.ts:258
Compute the vector transformation and assign the results to the input variables
Parameters
matrix
transformation matrix
vector
Original vector
result?
Vector3 = null
output vector
Returns
Returns the output vector
getRotationY()
getRotationY(
v):number
Defined in: src/math/MathUtil.ts:219
The rotation Angle around the Y-axis is obtained from the input vector
Parameters
v
input vector
Returns
number
Return the calculation result

