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

Vector4

Vector4

open 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.

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
open var w: Float
x
open var x: Float
y
open var y: Float
z
open var z: Float

Functions

NameSummary
add
fun add(v: Vector4): Vector4

Performs vector addition.
component1
operator fun component1(): Float
component2
operator fun component2(): Float
component3
operator fun component3(): Float
component4
operator fun component4(): Float
copy
fun copy(): Vector4

Returns a copy of this vector.
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.
equals
open operator override fun equals(other: Any?): Boolean
hashCode
open override fun hashCode(): Int
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