Skip to content

@orillusion/core


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() ​

static clampf(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() ​

static normalizeAngle(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() ​

static fract(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() ​

static getRandDirXZ(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() ​

static getRandDirXYZ(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 ​

Vector3

The Vector3 vector formed by the generated x, y, and z coordinate values


getCycleXYZ() ​

static getCycleXYZ(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 ​

Vector3

The Vector3 vector formed by the generated x, y, and z coordinate values


angle() ​

static angle(p1, p2): number

Defined in: src/math/MathUtil.ts:187

Calculate the Angle between two vectors

Parameters ​

p1 ​

Vector3

Vector 1

p2 ​

Vector3

Vector 2

Returns ​

number

Return the calculation result


angle_360() ​

static angle_360(from, to): number

Defined in: src/math/MathUtil.ts:203

Calculate the Angle between two vectors

Parameters ​

from ​

Vector3

Vector 1

to ​

Vector3

Vector 2

Returns ​

number

The Angle between two vectors


fromToRotation() ​

static fromToRotation(fromDirection, toDirection, target?): Quaternion

Defined in: src/math/MathUtil.ts:231

Calculate the quaternion from one direction to the other

Parameters ​

fromDirection ​

Vector3

Initial direction

toDirection ​

Vector3

The transformed direction

target? ​

Quaternion = null

The calculated quaternion is null by default and the result is returned

Returns ​

Quaternion

Quaternion The calculated quaternion returns a new instance created if target is null


getEularDir_yUp() ​

static getEularDir_yUp(v): Vector3

Defined in: src/math/MathUtil.ts:244

Get the Eular direction

Parameters ​

v ​

number

input value

Returns ​

Vector3

Return the calculation result


transformVector() ​

static transformVector(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 ​

Matrix4

transformation matrix

vector ​

Vector3

Original vector

result? ​

Vector3 = null

output vector

Returns ​

Vector3

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 ​

Vector3

input vector

Returns ​

number

Return the calculation result