Class Vector4

4D vector.

( class Vector4 implements Vector )

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(x?: number, y?: number, z?: number, w?: number): Vector4

Parameters

  • x?: number optional
  • y?: number optional
  • z?: number optional
  • w?: number optional

Returns

Vector4

Properties

public w: number

public x: number

public y: number

public z: number

Methods

public add(v: Vector4): Vector4

Adds v to this vector.

Parameters

Returns

Vector4

public addScalar(s: number): Vector4

Parameters

  • s: number

Returns

Vector4

public addVectors(a: Vector4, b: Vector4): Vector4

Sets this vector to a + b.

Parameters

Returns

Vector4

public applyMatrix4(m: Matrix4): Vector4

Parameters

Returns

Vector4

public ceil(): Vector4

Returns

Vector4

public clamp(min: Vector4, max: Vector4): Vector4

Parameters

Returns

Vector4

public clampScalar(min: number, max: number): Vector4

Parameters

  • min: number
  • max: number

Returns

Vector4

public clone(): Vector4

Clones this vector.

Returns

Vector4

public copy(v: Vector4): Vector4

Copies value of v to this vector.

Parameters

Returns

Vector4

public distanceTo(v: Vector): number

NOTE: Vector4 doesn't have the property.

distanceToSquared(v:T):number;

Parameters

Returns

number

public distanceToSquared(v: Vector): number

NOTE: Vector4 doesn't have the property.

distanceToSquared(v:T):number;

Parameters

Returns

number

public divideScalar(s: number): Vector4

Divides this vector by scalar s. Set vector to ( 0, 0, 0 ) if s == 0.

Parameters

  • s: number

Returns

Vector4

public dot(v: Vector4): number

Computes dot product of this vector and v.

Parameters

Returns

number

public equals(v: Vector4): boolean

Checks for strict equality of this vector and v.

Parameters

Returns

boolean

public floor(): Vector4

Returns

Vector4

public fromArray(xyzw: Array<number>): Array<number>

Parameters

  • xyzw: Array<number>

Returns

Array<number>

public getComponent(index: number): number

Parameters

  • index: number

Returns

number

public length(): number

Computes length of this vector.

Returns

number

public lengthManhattan(): number

Returns

number

public lengthSq(): number

Computes squared length of this vector.

Returns

number

public lerp(v: Vector4, alpha: number): Vector4

Linearly interpolate between this vector and v with alpha factor.

Parameters

Returns

Vector4

public max(v: Vector4): Vector4

Parameters

Returns

Vector4

public min(v: Vector4): Vector4

Parameters

Returns

Vector4

public multiplyScalar(s: number): Vector4

Multiplies this vector by scalar s.

Parameters

  • s: number

Returns

Vector4

public negate(): Vector4

Inverts this vector.

Returns

Vector4

public normalize(): Vector4

Normalizes this vector.

Returns

Vector4

public round(): Vector4

Returns

Vector4

public roundToZero(): Vector4

Returns

Vector4

public set(x: number, y: number, z: number, w: number): Vector4

Sets value of this vector.

Parameters

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

Returns

Vector4

public setAxisAngleFromQuaternion(q: Quaternion): Vector4

http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm

Parameters

Returns

Vector4

public setAxisAngleFromRotationMatrix(m: Matrix3): Vector4

http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm

Parameters

  • m: Matrix3

    assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)

Returns

Vector4

public setComponent(index: number, value: number)

Parameters

  • index: number
  • value: number

public setLength(l: number): Vector4

Normalizes this vector and multiplies it by l.

Parameters

  • l: number

Returns

Vector4

public setW(w: number): Vector2

Sets w component of this vector.

Parameters

  • w: number

Returns

Vector2

public setX(x: number): Vector2

Sets X component of this vector.

Parameters

  • x: number

Returns

Vector2

public setY(y: number): Vector2

Sets Y component of this vector.

Parameters

  • y: number

Returns

Vector2

public setZ(z: number): Vector2

Sets Z component of this vector.

Parameters

  • z: number

Returns

Vector2

public sub(v: Vector4): Vector4

Subtracts v from this vector.

Parameters

Returns

Vector4

public subVectors(a: Vector4, b: Vector4): Vector4

Sets this vector to a - b.

Parameters

Returns

Vector4

public toArray(): Array<number>

Returns

Array<number>