Skip to content

types.vector4

A 4D vector

Properties

NameDescription
xtype: number The x component
ytype: number The y component
ztype: number The z component
wtype: number The w component

Functions

new(opt_x : number, opt_y : number, opt_z : number, opt_w : number): types.vector4

Creates a new 4D vector

  • opt_x (number) (optional) The x component
  • opt_y (number) (optional) The y component
  • opt_z (number) (optional) The z component
  • opt_w (number) (optional) The w component
  • returns (types.vector4) A new vector instance

add(other : types.vector4): types.vector4

Adds another vector to this one and returns a new vector

sub(other : types.vector4): types.vector4

Subtracts another vector from this one and returns a new vector

mul(other : types.vector4 | number): types.vector4

Multiplies this vector by another vector or a number and returns a new vector

div(other : types.vector4 | number): types.vector4

Divides this vector by another vector or a number and returns a new vector

dist(other : types.vector4): number

Returns the distance between this vector and another

  • other (types.vector4) The other vector
  • returns (number) The distance

length(): number

Returns the length of this vector

  • returns (number) The length

dot(other : types.vector4): number

Returns the dot product of this vector and another

  • other (types.vector4) The other vector
  • returns (number) The dot product

normalize(): types.vector4

Returns a normalized (unit length) version of this vector