Vector4 - 4D vector

Constructor

class Vector4(x, y, z, w)

4D vector

Arguments:
  • x (float) – x-coordinate
  • y (float) – y-coordinate
  • z (float) – z-coordinate
  • w (float) – w-coordinate

Attributes

Vector4.x

float - default 0

Vector4.y

float - default 0

Vector4.z

float - default 0

Vector4.w

float - default 1

Methods

Vector4.clone()

Clones this vector

Returns:New instance identical to this vector
Rtype :Vector4()
Vector4.set(x, y, z, w)

Sets value of this vector

Arguments:
  • x (float) – x-coordinate
  • y (float) – y-coordinate
  • z (float) – z-coordinate
  • w (float) – w-coordinate
Returns:

This vector

Rtype :

Vector4()

Vector4.copy(v)

Copies value of v to this vector

Sets w to 1 if v.w is undefined

Arguments:
Returns:

This vector

Rtype :

Vector4()

Vector4.add(v1, v2)

Sets this vector to v1 + v2

Arguments:
Returns:

This vector

Rtype :

Vector4()

Vector4.addSelf(v)

Adds v to this vector

Arguments:
Returns:

This vector

Rtype :

Vector4()

Vector4.sub(v1, v2)

Sets this vector to v1 - v2

Arguments:
Vector4.subSelf(v)

Subtracts v from this vector

Arguments:
Returns:

This vector

Rtype :

Vector4()

Vector4.multiplyScalar(s)

Multiplies this vector by scalar s

Arguments:
  • s (float) – scalar
Returns:

This vector

Rtype :

Vector4()

Vector4.divideScalar(s)

Divides this vector by scalar s

Set vector to ( 0, 0, 0, 1 ) if s == 0

Arguments:
  • s (float) – scalar
Returns:

This vector

Rtype :

Vector4()

Vector4.negate()

Inverts this vector

Returns:This vector
Rtype :Vector4()
Vector4.dot(v)

Computes dot product of this vector and v

Arguments:
Returns:

dot product

Rtype :

float

Vector4.lengthSq()

Computes squared length of this vector

Returns:squared length
Rtype :float
Vector4.length()

Computes length of this vector

Returns:length
Rtype :float
Vector4.normalize()

Normalizes this vector

Returns:This vector
Rtype :Vector4()
Vector4.setLength(l)

Normalizes this vector and multiplies it by l

Returns:This vector
Rtype :Vector4()
Vector4.lerpSelf(v, alpha)

Linearly interpolate between this vector and v with alpha factor

Arguments:
  • v (Vector4) – vector
  • alpha (float) – interpolation factor
Returns:

This vector

Rtype :

Vector4()

Example

var a = new THREE.Vector4( 1, 0, 0, 0 );

Previous topic

Vector3 - 3D vector

Next topic

Vertex - Represents a vertex in space

This Page