# Vector4

data class Vector4(x: Double, y: Double, z: Double, w: Double) : LinearType<Vector4>

Double-precision 4D vector.

## Constructors

Vector4
fun Vector4(x: Double)
Vector4
fun Vector4(x: Double, y: Double, z: Double, w: Double)

Companion
object Companion

## Functions

distanceTo
fun distanceTo(other: Vector4): Double

Calculates the Euclidean distance to other.

div
open operator override fun div(scale: Double): Vector4
operator fun div(v: Vector4): Vector4
dot
infix fun dot(right: Vector4): Double

Calculates a dot product between this Vector4 and right.

get
operator fun get(i: Int): Double
minus
operator fun minus(d: Double): Vector4
open operator override fun minus(right: Vector4): Vector4
mix
fun mix(o: Vector4, mix: Double): Vector4
plus
operator fun plus(d: Double): Vector4
open operator override fun plus(right: Vector4): Vector4
squaredDistanceTo
fun squaredDistanceTo(other: Vector4): Double

Calculates the squared Euclidean distance to other.

times
open operator override fun times(scale: Double): Vector4
operator fun times(v: Vector4): Vector4
toDoubleArray
fun toDoubleArray(): DoubleArray

Casts to DoubleArray.

toInt
fun toInt(): IntVector4

Casts to IntVector4.

unaryMinus
operator fun unaryMinus(): Vector4

## Properties

div
val div: Vector3

Calculates Vector3 by dividing x, y, z by w.

length
val length: Double

The Euclidean length of the vector.

normalized
val normalized: Vector4

Returns a normalized version of the vector. (i.e. unit vector)

squaredLength
val squaredLength: Double

The squared Euclidean length of the vector.

w
val w: Double
x
val x: Double
xy
val xy: Vector2
xyz
val xyz: Vector3

Downcasts to Vector3 by discarding w.

xz
val xz: Vector2
y
val y: Double
yx
val yx: Vector2
yz
val yz: Vector2
z
val z: Double
zx
val zx: Vector2
zy
val zy: Vector2

## Extensions

clamp
fun Vector4.clamp(min: Vector4, max: Vector4): Vector4

Returns Vector4 whose value is limited between min and max per vector component.

map