V8 Javascript API

RS.Math.Vector4 Class Reference

[Math]

Description

A 4 Component vector.

Constructor

 Vector4( Object vector)
More...

Functions

Vector4 add( Vector4 rhs)
Adds rhs to this vector and stores the result in this vector. More...
 clone()
returns a copy of this vector.
Vector4 cross( Vector4 rhs)
Returns the cross product between this vector and rhs. More...
Number distance( Vector4 rhs)
Returns the distance between the point specified by this vector and rhs. More...
Vector4 divide( Vector4 rhs)
Divide rhs into this vector and stores the result in this vector. More...
Number dot( Vector4 rhs)
Returns the dot product between this vector and rhs. More...
Boolean equal( Vector4 rhs, Boolean use_tolerance)
Returns true if this vector equals rhs. More...
Boolean equal_with_tolerance( Vector4 rhs, Number tolerance)
Returns true if this vector equals rhs using tolerance. More...
Boolean is_colinear( Vector4 rhs)
Returns true if this vector and rhs are colinear. More...
Boolean is_null_vector( Number tolerance)
Checks if the vector is the null vector. More...
Number length()
Returns the length of this vector. More...
Vector4 multiply( Vector4 rhs)
Multiplies rhs with this vector and stores the result in this vector. More...
Vector4 normalize()
Normalizes this vector. More...
Vector4 rotate( Matrix4x4 matrix)
Rotates this vector by applying the provided matrix. More...
Vector4 rotate_to( Matrix4x4 matrix, Vector4 out)
Rotates this vector by applying the provided matrix. More...
Vector4 rotate_transpose( Matrix4x4 matrix)
Rotates this vector by the transpose of the provided matrix. More...
Vector4 rotate_transpose_to( Matrix4x4 matrix, Vector4 out)
Rotates this vector by the transpose of the provided matrix. More...
Vector4 scale( Number scale)
Scales this vector. More...
 set( Object rhs)
Sets this vector from an object. More...
Vector4 subtract( Vector4 rhs)
Subtracts rhs from this vector and stores the result in this vector. More...
String toString()
Returns a string describing this Object. More...
Vector4 transform( Matrix4x4 matrix)
Transforms this vector by applying the provided matrix. More...
Vector4 transform_to( Matrix4x4 matrix, Vector4 out)
Transforms this vector by applying the given matrix and copies the result into the out vector. More...
Vector4 transform_transpose( Matrix4x4 matrix)
Transforms this vector by the transpose of the matrix passed in. More...
Vector4 transform_transpose_to( Matrix4x4 matrix, Vector4 out)
Transforms this vector by the transpose of the matrix passed in and copies the result into the out vector. More...

Constructor

RS.​Math.​Vector4( Object vector)

Parameters

vector
Initial value. May be one of the following:
  • Object
  • Array
  • Vector4

Functions

Vector4 RS.​Math.​Vector4.add( Vector4 rhs)

Adds rhs to this vector and stores the result in this vector.

Parameters

rhs
the vector to add.

Returns

this

RS.​Math.​Vector4.clone()

returns a copy of this vector.

Vector4 RS.​Math.​Vector4.cross( Vector4 rhs)

Returns the cross product between this vector and rhs.

Parameters

rhs
Number RS.​Math.​Vector4.distance( Vector4 rhs)

Returns the distance between the point specified by this vector and rhs.

Parameters

rhs
Vector4 RS.​Math.​Vector4.divide( Vector4 rhs)

Divide rhs into this vector and stores the result in this vector.

Parameters

rhs
the vector to multiply.

Returns

this

Number RS.​Math.​Vector4.dot( Vector4 rhs)

Returns the dot product between this vector and rhs.

Parameters

rhs
Boolean RS.​Math.​Vector4.equal( Vector4 rhs, Boolean use_tolerance)

Returns true if this vector equals rhs.

Parameters

rhs
The vector to compare with.
use_tolerance
if supplied and true then use tolerance
Boolean RS.​Math.​Vector4.equal_with_tolerance( Vector4 rhs, Number tolerance)

Returns true if this vector equals rhs using tolerance.

Parameters

rhs
The vector to compare with.
tolerance
The tolerance to use or RS.Math.ALMOST_ZERO if not supplied.
Boolean RS.​Math.​Vector4.is_colinear( Vector4 rhs)

Returns true if this vector and rhs are colinear.

Parameters

rhs

Returns

True if this vector and rhs are colinear

Boolean RS.​Math.​Vector4.is_null_vector( Number tolerance)

Checks if the vector is the null vector.

Parameters

tolerance
Optional. A Number used to approximate the comparison.
Number RS.​Math.​Vector4.length()

Returns the length of this vector.

Vector4 RS.​Math.​Vector4.multiply( Vector4 rhs)

Multiplies rhs with this vector and stores the result in this vector.

Parameters

rhs
the vector to multiply.

Returns

this

Vector4 RS.​Math.​Vector4.normalize()

Normalizes this vector.

Returns

this

Vector4 RS.​Math.​Vector4.rotate( Matrix4x4 matrix)

Rotates this vector by applying the provided matrix.

Parameters

matrix
The matrix to apply.

Returns

this

Vector4 RS.​Math.​Vector4.rotate_to( Matrix4x4 matrix, Vector4 out)

Rotates this vector by applying the provided matrix.

Parameters

matrix
The matrix to apply.
out
Vector to write to

Returns

out

Vector4 RS.​Math.​Vector4.rotate_transpose( Matrix4x4 matrix)

Rotates this vector by the transpose of the provided matrix.

Parameters

matrix
The matrix to apply.

Returns

this

Vector4 RS.​Math.​Vector4.rotate_transpose_to( Matrix4x4 matrix, Vector4 out)

Rotates this vector by the transpose of the provided matrix.

Parameters

matrix
The matrix to apply.
out
Vector to write to

Returns

this

Vector4 RS.​Math.​Vector4.scale( Number scale)

Scales this vector.

Parameters

scale
Scale the scalar to apply.

Returns

this

RS.​Math.​Vector4.set( Object rhs)

Sets this vector from an object. The object may be of the following types: Vector4, and Array with 3 or more members or an Object. In the case of an object it must have the members x, y, z, and optionally w. If w is omitted then w will be set to 1.

Parameters

rhs
The object to set from. May be one of the following:
  • Object
  • Array
  • Vector4
Vector4 RS.​Math.​Vector4.subtract( Vector4 rhs)

Subtracts rhs from this vector and stores the result in this vector.

Parameters

rhs
the vector to subtract.

Returns

this

String RS.​Math.​Vector4.toString()

Returns a string describing this Object.

Returns

A String describing this Object.

Vector4 RS.​Math.​Vector4.transform( Matrix4x4 matrix)

Transforms this vector by applying the provided matrix.

Parameters

matrix
The matrix to apply.

Returns

this

Vector4 RS.​Math.​Vector4.transform_to( Matrix4x4 matrix, Vector4 out)

Transforms this vector by applying the given matrix and copies the result into the out vector.

Parameters

matrix
The matrix to apply.
out
Vector to write to

Returns

the result

Vector4 RS.​Math.​Vector4.transform_transpose( Matrix4x4 matrix)

Transforms this vector by the transpose of the matrix passed in.

Parameters

matrix
The matrix to apply.

Returns

this

Vector4 RS.​Math.​Vector4.transform_transpose_to( Matrix4x4 matrix, Vector4 out)

Transforms this vector by the transpose of the matrix passed in and copies the result into the out vector.

Parameters

matrix
The matrix to apply.
out
Vector to write to

Returns

out