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

Vector4

Vector4

data class Vector4(var x: Float, var y: Float, var z: Float, var w: Float)
A 4D vector class with x, y, z, and w components.
Parameters
JVM
NameSummary
x
The x component of the vector.
y
The y component of the vector.
z
The z component of the vector.
w
The w component of the vector.

Constructors

NameSummary
Vector4
constructor(v: Float)
Constructor that takes a single float value and initializes all components to that value.
constructor(x: Float, y: Float, z: Float, w: Float)

Properties

NameSummary
w
var w: Float
x
var x: Float
y
var y: Float
z
var z: Float

Functions

NameSummary
add
fun add(v: Vector4): Vector4
Performs vector addition.
distanceTo
fun distanceTo(v: Vector4): Float
Calculates the distance between two vectors.
div
operator fun div(v: Float): Vector4
Overloads the div operator to perform scalar division.
divide
fun divide(v: Float): Vector4
Performs scalar division.
dot
fun dot(v: Vector4): Float
Calculates the dot product of two vectors.
length
fun length(): Float
Calculates the length of the vector.
lerp
fun lerp(dest: Vector4, ratio: Float): Vector4
Linearly interpolates between two vectors.
minus
operator fun minus(v: Vector4): Vector4
Overloads the minus operator to perform vector subtraction.
multiply
fun multiply(v: Vector4): Vector4
Performs vector multiplication.
fun multiply(v: Float): Vector4
Performs scalar multiplication.
negate
fun negate(): Vector4
Negates the vector.
normalize
fun normalize(): Vector4
Normalizes the vector.
plus
operator fun plus(v: Vector4): Vector4
Overloads the plus operator to perform vector addition.
setW
fun setW(w: Float): Vector4
setX
fun setX(x: Float): Vector4
setY
fun setY(y: Float): Vector4
setZ
fun setZ(z: Float): Vector4
sub
fun sub(v: Vector4): Vector4
Performs vector subtraction.
times
operator fun times(v: Vector4): Vector4
Overloads the times operator to perform component-wise multiplication.
operator fun times(v: Float): Vector4
Overloads the times operator to perform scalar multiplication.
toString
open override fun toString(): String
unaryMinus
operator fun unaryMinus(): Vector4
Overloads the unary minus operator to negate the vector.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon