API reference
API reference
Select your platform
No SDKs available
No versions available

Vector4 Class

Modifiers: open
A 4D vector class with x, y, z, and w components.

Signature

open class Vector4(var x: Float, var y: Float, var z: Float, var w: Float)

Constructors

Vector4 ( v )
Constructor that takes a single float value and initializes all components to that value.
Signature
constructor(v: Float)
Parameters
v: Float
  The value to initialize all components with.
Returns
Vector4 ( x , y , z , w )
Signature
constructor(x: Float, y: Float, z: Float, w: Float)
Parameters
x: Float
  The x component of the vector.
y: Float
  The y component of the vector.
z: Float
  The z component of the vector.
w: Float
  The w component of the vector.
Returns

Properties

w : Float
[Get][Set]
Signature
open var w: Float
x : Float
[Get][Set]
Signature
open var x: Float
y : Float
[Get][Set]
Signature
open var y: Float
z : Float
[Get][Set]
Signature
open var z: Float

Functions

add ( v )
Performs vector addition.
Signature
fun add(v: Vector4): Vector4
Parameters
  The vector to add.
Returns
  The resulting vector.
component1 ()
Signature
operator fun component1(): Float
Returns
Float
component2 ()
Signature
operator fun component2(): Float
Returns
Float
component3 ()
Signature
operator fun component3(): Float
Returns
Float
component4 ()
Signature
operator fun component4(): Float
Returns
Float
copy ()
Returns a copy of this vector.
Signature
fun copy(): Vector4
Returns
  A copy of this vector.
distanceTo ( v )
Calculates the distance between two vectors.
Signature
fun distanceTo(v: Vector4): Float
Parameters
  The other vector to calculate the distance to.
Returns
Float
  The distance between the two vectors.
div ( v )
Overloads the div operator to perform scalar division.
Signature
operator fun div(v: Float): Vector4
Parameters
v: Float
  The scalar to divide by.
Returns
  The resulting vector.
divide ( v )
Performs scalar division.
Signature
fun divide(v: Float): Vector4
Parameters
v: Float
  The scalar to divide by.
Returns
  The resulting vector.
dot ( v )
Calculates the dot product of two vectors.
Signature
fun dot(v: Vector4): Float
Parameters
  The vector to calculate the dot product with.
Returns
Float
  The dot product.
equals ( other )
Signature
open operator override fun equals(other: Any?): Boolean
Parameters
other: Any?
Returns
Boolean
hashCode ()
Signature
open override fun hashCode(): Int
Returns
Int
length ()
Calculates the length of the vector.
Signature
fun length(): Float
Returns
Float
  The length of the vector.
lerp ( dest , ratio )
Linearly interpolates between two vectors.
Signature
fun lerp(dest: Vector4, ratio: Float): Vector4
Parameters
dest: Vector4
  The destination vector to interpolate towards.
ratio: Float
  The interpolation ratio, where 0 means no interpolation (i.e., the current vector) and 1 means full interpolation (i.e., the destination vector).
Returns
  The interpolated vector.
minus ( v )
Overloads the minus operator to perform vector subtraction.
Signature
operator fun minus(v: Vector4): Vector4
Parameters
  The vector to subtract.
Returns
  The resulting vector.
multiply ( v )
Performs vector multiplication.
Signature
fun multiply(v: Vector4): Vector4
Parameters
  The vector to multiply.
Returns
  The resulting vector.
multiply ( v )
Performs scalar multiplication.
Signature
fun multiply(v: Float): Vector4
Parameters
v: Float
  The scalar to multiply by.
Returns
  The resulting vector.
negate ()
Negates the vector.
Signature
fun negate(): Vector4
Returns
  The negated vector.
normalize ()
Normalizes the vector.
Signature
fun normalize(): Vector4
Returns
  A new vector representing the normalization of this vector, or (0, 0, 0, 0) if the length of this vector is 0.
plus ( v )
Overloads the plus operator to perform vector addition.
Signature
operator fun plus(v: Vector4): Vector4
Parameters
  The vector to add.
Returns
  The resulting vector.
setW ( w )
Signature
fun setW(w: Float): Vector4
Parameters
w: Float
Returns
setX ( x )
Signature
fun setX(x: Float): Vector4
Parameters
x: Float
Returns
setY ( y )
Signature
fun setY(y: Float): Vector4
Parameters
y: Float
Returns
setZ ( z )
Signature
fun setZ(z: Float): Vector4
Parameters
z: Float
Returns
sub ( v )
Performs vector subtraction.
Signature
fun sub(v: Vector4): Vector4
Parameters
  The vector to subtract.
Returns
  The resulting vector.
times ( v )
Overloads the times operator to perform component-wise multiplication.
Signature
operator fun times(v: Vector4): Vector4
Parameters
  The vector to multiply.
Returns
  The resulting vector.
times ( v )
Overloads the times operator to perform scalar multiplication.
Signature
operator fun times(v: Float): Vector4
Parameters
v: Float
  The scalar to multiply by.
Returns
  The resulting vector.
toString ()
Signature
open override fun toString(): String
Returns
String
unaryMinus ()
Overloads the unary minus operator to negate the vector.
Signature
operator fun unaryMinus(): Vector4
Returns
  The negated vector.
Did you find this page helpful?