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 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
  • zh

    对 a b 的绝对值进行比较大小,返回绝对值最大的值。

    Parameters

    • a: number

      number

    • b: number

      number

    Returns number

absMaxComponent

  • zh

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

    Parameters

    Returns number

    绝对值最大的分量

approx

  • approx(a: number, b: number, maxDiff: number): boolean
  • Tests whether or not the arguments have approximately the same value by given maxDiff

    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
  • Clamps a value between a minimum float and maximum float value.

    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

equals

  • equals(a: number, b: number): boolean
  • Tests whether or not the arguments have approximately the same value, within an absolute
    or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
    than or equal to 1.0, and a relative tolerance is used for larger values)

    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
  • Returns ratio of a value within a given range.

    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

nextPow2

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

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
  • Returns a pseudo-random integer between min (inclusive) and max (exclusive).

    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
  • Returns a floating-point random number between min (inclusive) and max (exclusive).

    method

    randomRange

    Parameters

    • min: number
    • max: number

    Returns number

    The random number.

randomRangeInt

  • randomRangeInt(min: number, max: number): number
  • Returns a random integer between min (inclusive) and max (exclusive).

    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
  • The convenient method to create a new 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
  • Returns float remainder for 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
  • Constructs a Size object.

    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