Options
All
  • Public
  • Public/Protected
  • All
Menu

External 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)

Let _a

_a: number = 0

Let _a

_a: number = 0

Let _a00

_a00: number = 0

Let _a00

_a00: number = 0

Let _a01

_a01: number = 0

Let _a01

_a01: number = 0

Let _a02

_a02: number = 0

Let _a02

_a02: number = 0

Let _a03

_a03: number = 0

Let _a10

_a10: number = 0

Let _a10

_a10: number = 0

Let _a11

_a11: number = 0

Let _a11

_a11: number = 0

Let _a12

_a12: number = 0

Let _a12

_a12: number = 0

Let _a13

_a13: number = 0

Let _a20

_a20: number = 0

Let _a20

_a20: number = 0

Let _a21

_a21: number = 0

Let _a21

_a21: number = 0

Let _a22

_a22: number = 0

Let _a22

_a22: number = 0

Let _a23

_a23: number = 0

Let _a30

_a30: number = 0

Let _a31

_a31: number = 0

Let _a32

_a32: number = 0

Let _a33

_a33: number = 0

Let _b

_b: number = 0

Let _b

_b: number = 0

Let _c

_c: number = 0

Let _d

_d: number = 0

Const _d2r

_d2r: number = Math.PI / 180.0

Let _g

_g: number = 0

Let _h

_h: number = 0

Let _r

_r: number = 0

Const _r2d

_r2d: number = 180.0 / Math.PI

Let _tx

_tx: number = 0

Let _ty

_ty: number = 0

Let _w

_w: number = 0

Let _w

_w: number = 0

Let _w

_w: number = 0

Let _x

_x: number = 0

Let _x

_x: number = 0

Let _x

_x: number = 0

Let _x

_x: number = 0

Let _x

_x: number = 0

Let _y

_y: number = 0

Let _y

_y: number = 0

Let _y

_y: number = 0

Let _y

_y: number = 0

Let _y

_y: number = 0

Let _z

_z: number = 0

Let _z

_z: number = 0

Let _z

_z: number = 0

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 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
  • Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes.

    Parameters

    • x: number
    • y: number

    Returns number

interleave3

  • interleave3(x: number, y: number, z: number): number
  • Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes.

    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 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  • Computes log base 10 of v.

    Parameters

    • v: number

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

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
  • Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page).

    Parameters

    • v: number

    Returns number

nextPow2

  • nextPow2(val: number): number

nextPow2

  • nextPow2(v: 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

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

      相比较的矩形。

    Returns Rect

    new Rect(rect)

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

    Parameters

    • Optional x: undefined | number

      矩形在 x 轴上的最小值。

    • Optional y: undefined | number

      矩形在 y 轴上的最小值。

    • Optional width: undefined | number

      矩形的宽度。

    • Optional height: undefined | number

      矩形的高度。

    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

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