Options
All
  • Public
  • Public/Protected
  • All
Menu

Module math

Index

Variables

Const EPSILON

EPSILON: 0.000001 = 0.000001

Const INT_BITS

INT_BITS: 32 = 32

Bit twiddling hacks for JavaScript.

Author: Mikola Lysenko

Ported from Stanford bit twiddling hack library: http://graphics.stanford.edu/~seander/bithacks.html

Const INT_MAX

INT_MAX: 2147483647 = 2147483647

Const INT_MIN

INT_MIN: number = -1 << (INT_BITS - 1)

Const REVERSE_TABLE

REVERSE_TABLE: number[] = new Array(256)

Const _d2r

_d2r: number = Math.PI / 180.0

Const _r2d

_r2d: number = 180.0 / Math.PI

Const halfToRad

halfToRad: number = 0.5 * Math.PI / 180.0

Const m3_1

m3_1: Mat3 = new Mat3()

Const m3_1

m3_1: Mat3 = new Mat3()

Const preTransforms

preTransforms: ReadonlyArray<ReadonlyArray<number>> = Object.freeze([Object.freeze([1, 0, 0, 1]), // SurfaceTransform.IDENTITYObject.freeze([0, 1, -1, 0]), // SurfaceTransform.ROTATE_90Object.freeze([-1, 0, 0, -1]), // SurfaceTransform.ROTATE_180Object.freeze([0, -1, 1, 0]), // SurfaceTransform.ROTATE_270])

Const qt_1

qt_1: Quat = new Quat()

Const qt_2

qt_2: Quat = new Quat()

Const random

random: random = Math.random
method

random

Const toFloat

toFloat: number = 1 / 255

Const v2_1

v2_1: Vec2 = new Vec2()

Const v2_2

v2_2: Vec2 = new Vec2()

Const v3_1

v3_1: Vec3 = new Vec3()

Const v3_1

v3_1: Vec3 = new Vec3()

Const v3_1

v3_1: Vec3 = new Vec3()

Const v3_1

v3_1: Vec3 = new Vec3()

Const v3_2

v3_2: Vec3 = new Vec3()

Const v3_2

v3_2: Vec3 = new Vec3()

Functions

abs

  • abs(v: number): number

absMax

  • absMax(a: number, b: number): number
  • 对 a b 的绝对值进行比较大小,返回绝对值最大的值。

    Parameters

    • a: number

      number

    • b: number

      number

    Returns number

absMaxComponent

  • 对所有分量的绝对值进行比较大小,返回绝对值最大的分量。

    Parameters

    Returns number

    绝对值最大的分量

approx

  • approx(a: number, b: number, maxDiff: number): boolean
  • 通过给定的最大差异,测试参数是否具有近似相同的值。

    Parameters

    • a: number

      The first number to test.

    • b: number

      The second number to test.

    • maxDiff: number

      Maximum difference.

    Returns boolean

    True if the numbers are approximately equal, false otherwise.

clamp

  • clamp(val: number, min: number, max: number): number
  • 返回最小浮点数和最大浮点数之间的一个数值。可以使用 clamp 函数将不断变化的数值限制在范围内。

    Parameters

    • val: number
    • min: number
    • max: number

    Returns number

clamp01

  • clamp01(val: number): number

color

  • color(other: Color | string): Color
  • color(r?: undefined | number, g?: undefined | number, b?: undefined | number, a?: undefined | number): Color

countTrailingZeros

  • countTrailingZeros(v: number): number

deinterleave2

  • deinterleave2(v: number, n: number): number

deinterleave3

  • deinterleave3(v: number, n: number): number
  • Extracts nth interleaved component of a 3-tuple.

    Parameters

    • v: number
    • n: number

    Returns number

equals

  • equals(a: number, b: number): boolean
  • 在glMatrix的绝对或相对容差范围内,测试参数是否具有近似相同的值。
    EPSILON(小于等于1.0的值采用绝对公差,大于1.0的值采用相对公差)

    Parameters

    • a: number

      The first number to test.

    • b: number

      The second number to test.

    Returns boolean

    True if the numbers are approximately equal, false otherwise.

interleave2

  • interleave2(x: number, y: number): number
  • 将两个 16 位数字按位交错编码。有利于在快速四叉树中使用。

    Parameters

    • x: number
    • y: number

    Returns number

interleave3

  • interleave3(x: number, y: number, z: number): number
  • 将三个数字按位交错编码,每个数字占十位。有利于在八叉树中使用。

    Parameters

    • x: number
    • y: number
    • z: number

    Returns number

inverseLerp

  • inverseLerp(from: number, to: number, value: number): number
  • 返回给定范围内的值的比率。

    Parameters

    • from: number

      Start value.

    • to: number

      End value.

    • value: number

      Given value.

    Returns number

    The ratio between [from, to].

isPow2

  • isPow2(v: number): boolean

lerp

  • lerp(from: number, to: number, ratio: number): number
  • Parameters

    • from: number
    • to: number
    • ratio: number

      The interpolation coefficient.

    Returns number

log10

  • log10(v: number): 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2
  • 计算以 10 为底的 v 的对数。

    Parameters

    • v: number

    Returns 1 | 0 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2

log2

  • log2(v: number): number

mat4

  • mat4(other: Mat4): Mat4
  • mat4(m00?: undefined | number, m01?: undefined | number, m02?: undefined | number, m03?: undefined | number, m10?: undefined | number, m11?: undefined | number, m12?: undefined | number, m13?: undefined | number, m20?: undefined | number, m21?: undefined | number, m22?: undefined | number, m23?: undefined | number, m30?: undefined | number, m31?: undefined | number, m32?: undefined | number, m33?: undefined | number): Mat4
  • Parameters

    Returns Mat4

  • Parameters

    • Optional m00: undefined | number
    • Optional m01: undefined | number
    • Optional m02: undefined | number
    • Optional m03: undefined | number
    • Optional m10: undefined | number
    • Optional m11: undefined | number
    • Optional m12: undefined | number
    • Optional m13: undefined | number
    • Optional m20: undefined | number
    • Optional m21: undefined | number
    • Optional m22: undefined | number
    • Optional m23: undefined | number
    • Optional m30: undefined | number
    • Optional m31: undefined | number
    • Optional m32: undefined | number
    • Optional m33: undefined | number

    Returns Mat4

max

  • max(x: number, y: number): number

min

  • min(x: number, y: number): number

nextCombination

  • nextCombination(v: number): number

nextPow2

  • nextPow2(v: number): number
  • 计算大于等于v的最小的二的整数次幂的数字。

    Parameters

    • v: number

    Returns number

nextPow2

  • nextPow2(val: number): number

parity

  • parity(v: number): number

pingPong

  • pingPong(t: number, length: number): number
  • Returns time wrapped in ping-pong mode.

    Parameters

    • t: number

      Time start at 0.

    • length: number

      Time of one cycle.

    Returns number

    The time wrapped in the first cycle.

popCount

  • popCount(v: number): number

prevPow2

  • prevPow2(v: number): number
  • 计算小于等于v的最小的二的整数次幂的数字。

    Parameters

    • v: number

    Returns number

pseudoRandom

  • pseudoRandom(seed: number): number
  • Linear congruential generator using Hull-Dobell Theorem.

    Parameters

    • seed: number

      The random seed.

    Returns number

    The pseudo random.

pseudoRandomRange

  • pseudoRandomRange(seed: number, min: number, max: number): number
  • Returns a floating-point pseudo-random number between min (inclusive) and max (exclusive).

    Parameters

    • seed: number
    • min: number
    • max: number

    Returns number

    The random number.

pseudoRandomRangeInt

  • pseudoRandomRangeInt(seed: number, min: number, max: number): number
  • 返回最小(包含)和最大(不包含)之间的浮点伪随机数。

    Parameters

    • seed: number
    • min: number
    • max: number

    Returns number

    The random integer.

quat

  • quat(other: Quat): Quat
  • quat(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Quat

randomRange

  • randomRange(min: number, max: number): number
  • 返回最小(包含)和最大(不包含)之间的浮点随机数。

    method

    randomRange

    Parameters

    • min: number
    • max: number

    Returns number

    The random number.

randomRangeInt

  • randomRangeInt(min: number, max: number): number
  • 返回最小(包含)和最大(不包含)之间的随机整数。

    Parameters

    • min: number
    • max: number

    Returns number

    The random integer.

rect

  • rect(rect: Rect): Rect
  • rect(x?: undefined | number, y?: undefined | number, width?: undefined | number, height?: undefined | number): Rect
  • 构造与指定矩形相等的矩形。等价于 new Rect(rect)

    Parameters

    • rect: Rect

      Specified Rect.

    Returns Rect

    new Rect(rect)

  • en

    The convenient method to create a new Rect.

    zh

    构造具有指定的最小值和尺寸的矩形,等价于new Rect(x, y, width, height)

    Parameters

    • Optional x: undefined | number

      The minimum X coordinate of the rectangle.

    • Optional y: undefined | number

      The minimum Y coordinate of the rectangle.

    • Optional width: undefined | number

      The width of the rectangle, measured from the X position.

    • Optional height: undefined | number

      The height of the rectangle, measured from the Y position.

    Returns Rect

    new Rect(x, y, width, height)

repeat

  • repeat(t: number, length: number): number
  • 返回t / length的浮点余数。

    Parameters

    • t: number

      Time start at 0.

    • length: number

      Time of one cycle.

    Returns number

    The Time wrapped in the first cycle.

reverse

  • reverse(v: number): number

sign

  • sign(v: number): number

size

  • size(other: Size): Size
  • size(width?: undefined | number, height?: undefined | number): Size
  • 等价于 new Size(other)

    Parameters

    • other: Size

      Specified Size.

    Returns Size

    new Size(other)

  • en

    Constructs a Size object.

    zh

    等价于 new Size(x, y)

    Parameters

    • Optional width: undefined | number

      Specified width

    • Optional height: undefined | number

      Specified height

    Returns Size

    new Size(w, h)

toDegree

  • toDegree(a: number): number

toRadian

  • toRadian(a: number): number

v2

  • v2(other: Vec2): Vec2
  • v2(x?: undefined | number, y?: undefined | number): Vec2

v3

  • v3(other: Vec3): Vec3
  • v3(x?: undefined | number, y?: undefined | number, z?: undefined | number): Vec3

v4

  • v4(other: Vec4): Vec4
  • v4(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): Vec4

Generated using TypeDoc