Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vec4

四维向量。

Hierarchy

Index

Constructors

constructor

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

Properties

w

w: number

w 分量。

x

x: number

x 分量。

y

y: number

y 分量。

z

z: number

z 分量。

Static NEGONE

NEGONE: {} = Object.freeze(new Vec4(-1, -1, -1, -1))

Type declaration

Static ONE

ONE: {} = Object.freeze(new Vec4(1, 1, 1, 1))

Type declaration

Static ZERO

ZERO: {} = Object.freeze(new Vec4(0, 0, 0, 0))

Type declaration

Methods

add

  • add(other: Vec4): this

add4f

  • add4f(x: number, y: number, z: number, w: number): this
  • 向量加法。将当前向量与指定分量的向量相加

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • w: number

      The w value of specified vector

    Returns this

clampf

  • clampf(minInclusive: Vec4, maxInclusive: Vec4): this
  • 设置当前向量的值,使其各个分量都处于指定的范围内。

    Parameters

    • minInclusive: Vec4

      Minimum value allowed

    • maxInclusive: Vec4

      Maximum value allowed

    Returns this

    this

clone

cross

  • cross(vector: Vec4): this
  • 向量叉乘。视当前向量和指定向量为三维向量(舍弃 w 分量),将当前向量左叉乘指定向量

    Parameters

    Returns this

divide

  • divide(other: Vec4): this
  • 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。

    Parameters

    • other: Vec4

      specified vector

    Returns this

divide4f

  • divide4f(x: number, y: number, z: number, w: number): this
  • 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • w: number

      The w value of specified vector

    Returns this

dot

  • dot(vector: Vec4): number

equals

  • equals(other: Vec4, epsilon?: number): boolean
  • 判断当前向量是否在误差范围内与指定向量相等。

    Parameters

    • other: Vec4

      Specified vector

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

equals4f

  • equals4f(x: number, y: number, z: number, w: number, epsilon?: number): boolean
  • 判断当前向量是否在误差范围内与指定分量的向量相等。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • w: number

      The w value of specified vector

    • Default value epsilon: number = EPSILON

      The error allowed. It`s should be a non-negative number.

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

length

  • length(): number

lengthSqr

  • lengthSqr(): number

lerp

  • lerp(to: Vec4, ratio: number): this
  • 根据指定的插值比率,从当前向量到目标向量之间做插值。

    Parameters

    • to: Vec4

      Target vector

    • ratio: number

      The interpolation coefficient.The range is [0,1].

    Returns this

multiply

  • multiply(other: Vec4): this

multiply4f

  • multiply4f(x: number, y: number, z: number, w: number): this
  • 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • w: number

      The w value of specified vector

    Returns this

multiplyScalar

  • multiplyScalar(scalar: number): this
  • 向量数乘。将当前向量数乘指定标量

    Parameters

    • scalar: number

      scalar number

    Returns this

negative

  • negative(): this

normalize

  • normalize(): this

set

  • set(other: Vec4): any
  • set(x?: undefined | number, y?: undefined | number, z?: undefined | number, w?: undefined | number): any
  • 设置当前向量使其与指定向量相等。

    Parameters

    • other: Vec4

      Specified vector

    Returns any

    this

  • 设置当前向量的具体分量值。

    Parameters

    • Optional x: undefined | number

      x value

    • Optional y: undefined | number

      y value

    • Optional z: undefined | number

      z value

    • Optional w: undefined | number

      w value

    Returns any

    this

strictEquals

  • strictEquals(other: Vec4): boolean
  • 判断当前向量是否与指定向量相等。

    Parameters

    • other: Vec4

      specified vector

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

strictEquals4f

  • strictEquals4f(x: number, y: number, z: number, w: number): boolean
  • 判断当前向量是否与指定分量的向量相等。

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • w: number

      The w value of specified vector

    Returns boolean

    Returns true when the components of both vectors are equal within the specified range of error; otherwise it returns false.

subtract

  • subtract(other: Vec4): this

subtract4f

  • subtract4f(x: number, y: number, z: number, w: number): this
  • 向量减法。将当前向量减去指定分量的向量

    Parameters

    • x: number

      The x value of specified vector

    • y: number

      The y value of specified vector

    • z: number

      The z value of specified vector

    • w: number

      The w value of specified vector

    Returns this

toString

  • toString(): string

transformMat4

  • transformMat4(matrix: Mat4): this

Static add

  • add<Out>(out: Out, a: Out, b: Out): Out

Static ceil

  • ceil<Out>(out: Out, a: Out): Out

Static clone

  • clone<Out>(a: Out): Vec4

Static copy

  • copy<Out>(out: Out, a: Out): Out

Static distance

  • distance<Out>(a: Out, b: Out): number

Static divide

  • divide<Out>(out: Out, a: Out, b: Out): Out

Static dot

  • dot<Out>(a: Out, b: Out): number

Static equals

  • equals<Out>(a: Out, b: Out, epsilon?: number): boolean
  • 排除浮点数误差的向量近似等价判断

    Type parameters

    Parameters

    • a: Out
    • b: Out
    • Default value epsilon: number = EPSILON

    Returns boolean

Static floor

  • floor<Out>(out: Out, a: Out): Out

Static fromArray

  • fromArray<Out>(out: Out, arr: IWritableArrayLike<number>, ofs?: number): Out
  • 数组转向量

    Type parameters

    Parameters

    • out: Out
    • arr: IWritableArrayLike<number>
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static inverse

  • inverse<Out>(out: Out, a: Out): Out

Static inverseSafe

  • inverseSafe<Out>(out: Out, a: Out): Out

Static len

  • len<Out>(a: Out): number

Static lengthSqr

  • lengthSqr<Out>(a: Out): number

Static lerp

  • lerp<Out>(out: Out, a: Out, b: Out, t: number): Out

Static max

  • max<Out>(out: Out, a: Out, b: Out): Out

Static min

  • min<Out>(out: Out, a: Out, b: Out): Out

Static multiply

  • multiply<Out>(out: Out, a: Out, b: Out): Out

Static multiplyScalar

  • multiplyScalar<Out>(out: Out, a: Out, b: number): Out

Static negate

  • negate<Out>(out: Out, a: Out): Out

Static normalize

  • normalize<Out>(out: Out, a: Out): Out

Static random

  • random<Out>(out: Out, scale?: undefined | number): Out
  • 生成一个在单位球体上均匀分布的随机向量

    Type parameters

    Parameters

    • out: Out
    • Optional scale: undefined | number

      vector length

    Returns Out

Static round

  • round<Out>(out: Out, a: Out): Out

Static scaleAndAdd

  • scaleAndAdd<Out>(out: Out, a: Out, b: Out, scale: number): Out

Static set

  • set<Out>(out: Out, x: number, y: number, z: number, w: number): Out

Static squaredDistance

  • squaredDistance<Out>(a: Out, b: Out): number

Static strictEquals

  • strictEquals<Out>(a: Out, b: Out): boolean

Static subtract

  • subtract<Out>(out: Out, a: Out, b: Out): Out

Static toArray

  • toArray<Out>(out: Out, v: IVec4Like, ofs?: number): Out
  • 向量转数组

    Type parameters

    • Out: IWritableArrayLike<number>

    Parameters

    • out: Out
    • v: IVec4Like
    • Default value ofs: number = 0

      Array Start Offset

    Returns Out

Static transformAffine

  • transformAffine<Out, VecLike, MatLike>(out: Out, v: VecLike, m: MatLike): Out

Static transformMat4

  • transformMat4<Out, MatLike>(out: Out, a: Out, m: MatLike): Out

Static transformQuat

  • transformQuat<Out, QuatLike>(out: Out, a: Out, q: QuatLike): Out

Generated using TypeDoc