Skip to content

Class: MathUtil

Built-in mathematical basic calculation factory function

Constructors

Methods

Constructors

constructor

new MathUtil(): MathUtil

Returns

MathUtil

Methods

clampf

clampf(value, min_inclusive, max_inclusive): number

Limit the value to a certain range

Parameters

NameTypeDescription
valuenumberOriginal value
min_inclusivenumberminimum value
max_inclusivenumbermaximum value

Returns

number

Return the calculation result

Defined in

src/math/MathUtil.ts:107


normalizeAngle

normalizeAngle(a): number

Normalize the Angle so that it is limited to the range [-180, 180]

Parameters

NameTypeDescription
anumberAngle of input

Returns

number

Return the processing result

Defined in

src/math/MathUtil.ts:121


fract

fract(v): number

Returns the fractional part of a number

Parameters

NameTypeDescription
vnumberinput value

Returns

number

Return the result

Defined in

src/math/MathUtil.ts:136


getRandDirXZ

getRandDirXZ(r): Object

Generate a random pair of x and z coordinates that fall within the radius of the circle

Parameters

NameTypeDescription
rnumberradius

Returns

Object

The generated x, z results

NameType
xnumber
znumber

Defined in

src/math/MathUtil.ts:145


getRandDirXYZ

getRandDirXYZ(r): Vector3

Generate a random pair of x, y, and z coordinates that fall within the radius of the sphere

Parameters

NameTypeDescription
rnumberradius

Returns

Vector3

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

Defined in

src/math/MathUtil.ts:158


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

NameTypeDescription
rnumberradius

Returns

Vector3

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

Defined in

src/math/MathUtil.ts:172


angle

angle(p1, p2): number

Calculate the Angle between two vectors

Parameters

NameTypeDescription
p1Vector3Vector 1
p2Vector3Vector 2

Returns

number

Return the calculation result

Defined in

src/math/MathUtil.ts:187


angle_360

angle_360(from, to): number

Calculate the Angle between two vectors

Parameters

NameTypeDescription
fromVector3Vector 1
toVector3Vector 2

Returns

number

The Angle between two vectors

Defined in

src/math/MathUtil.ts:203


fromToRotation

fromToRotation(fromDirection, toDirection, target?): Quaternion

Calculate the quaternion from one direction to the other

Parameters

NameTypeDefault valueDescription
fromDirectionVector3undefinedInitial direction
toDirectionVector3undefinedThe transformed direction
targetQuaternionnullThe 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

Version

Orillusion3D 0.5.1

Defined in

src/math/MathUtil.ts:232


getEularDir_yUp

getEularDir_yUp(v): Vector3

Get the Eular direction

Parameters

NameTypeDescription
vnumberinput value

Returns

Vector3

Return the calculation result

Defined in

src/math/MathUtil.ts:245


transformVector

transformVector(matrix, vector, result?): Vector3

Compute the vector transformation and assign the results to the input variables

Parameters

NameTypeDefault valueDescription
matrixMatrix4undefinedtransformation matrix
vectorVector3undefinedOriginal vector
resultVector3nulloutput vector

Returns

Vector3

Returns the output vector

Defined in

src/math/MathUtil.ts:259


getRotationY

getRotationY(v): number

The rotation Angle around the Y-axis is obtained from the input vector

Parameters

NameTypeDescription
vVector3input vector

Returns

number

Return the calculation result

Defined in

src/math/MathUtil.ts:219

Released under the MIT License