Class: MathUtil
Built-in mathematical basic calculation factory function
Constructors
Methods
- clampf
- normalizeAngle
- fract
- getRandDirXZ
- getRandDirXYZ
- getCycleXYZ
- angle
- angle_360
- fromToRotation
- getEularDir_yUp
- transformVector
- getRotationY
Constructors
constructor
• new MathUtil(): MathUtil
Returns
Methods
clampf
▸ clampf(value
, min_inclusive
, max_inclusive
): number
Limit the value to a certain range
Parameters
Name | Type | Description |
---|---|---|
value | number | Original value |
min_inclusive | number | minimum value |
max_inclusive | number | maximum value |
Returns
number
Return the calculation result
Defined in
normalizeAngle
▸ normalizeAngle(a
): number
Normalize the Angle so that it is limited to the range [-180, 180]
Parameters
Name | Type | Description |
---|---|---|
a | number | Angle of input |
Returns
number
Return the processing result
Defined in
fract
▸ fract(v
): number
Returns the fractional part of a number
Parameters
Name | Type | Description |
---|---|---|
v | number | input value |
Returns
number
Return the result
Defined in
getRandDirXZ
▸ getRandDirXZ(r
): Object
Generate a random pair of x and z coordinates that fall within the radius of the circle
Parameters
Name | Type | Description |
---|---|---|
r | number | radius |
Returns
Object
The generated x, z results
Name | Type |
---|---|
x | number |
z | number |
Defined in
getRandDirXYZ
▸ getRandDirXYZ(r
): Vector3
Generate a random pair of x, y, and z coordinates that fall within the radius of the sphere
Parameters
Name | Type | Description |
---|---|---|
r | number | radius |
Returns
The Vector3 vector formed by the generated x, y, and z coordinate values
Defined in
getCycleXYZ
▸ getCycleXYZ(r
): Vector3
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
Name | Type | Description |
---|---|---|
r | number | radius |
Returns
The Vector3 vector formed by the generated x, y, and z coordinate values
Defined in
angle
▸ angle(p1
, p2
): number
Calculate the Angle between two vectors
Parameters
Name | Type | Description |
---|---|---|
p1 | Vector3 | Vector 1 |
p2 | Vector3 | Vector 2 |
Returns
number
Return the calculation result
Defined in
angle_360
▸ angle_360(from
, to
): number
Calculate the Angle between two vectors
Parameters
Name | Type | Description |
---|---|---|
from | Vector3 | Vector 1 |
to | Vector3 | Vector 2 |
Returns
number
The Angle between two vectors
Defined in
fromToRotation
▸ fromToRotation(fromDirection
, toDirection
, target?
): Quaternion
Calculate the quaternion from one direction to the other
Parameters
Name | Type | Default value | Description |
---|---|---|---|
fromDirection | Vector3 | undefined | Initial direction |
toDirection | Vector3 | undefined | 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
Version
Orillusion3D 0.5.1
Defined in
getEularDir_yUp
▸ getEularDir_yUp(v
): Vector3
Get the Eular direction
Parameters
Name | Type | Description |
---|---|---|
v | number | input value |
Returns
Return the calculation result
Defined in
transformVector
▸ transformVector(matrix
, vector
, result?
): Vector3
Compute the vector transformation and assign the results to the input variables
Parameters
Name | Type | Default value | Description |
---|---|---|---|
matrix | Matrix4 | undefined | transformation matrix |
vector | Vector3 | undefined | Original vector |
result | Vector3 | null | output vector |
Returns
Returns the output vector
Defined in
getRotationY
▸ getRotationY(v
): number
The rotation Angle around the Y-axis is obtained from the input vector
Parameters
Name | Type | Description |
---|---|---|
v | Vector3 | input vector |
Returns
number
Return the calculation result