class Vector4


Represents a four-dimensional position in space.

Summary

Public companion functions

Vector4
abs(vector: Vector4)

Returns the absolute values of each component of the vector.

Float
angleBetween(vector1: Vector4, vector2: Vector4)

Returns the angle between this vector and other vector in degrees.

Float
distance(vector1: Vector4, vector2: Vector4)

Returns the distance between this vector and the other vector.

Vector4
fromValue(value: Float)

Creates a new vector with all components set to value.

Vector4
lerp(start: Vector4, end: Vector4, ratio: Float)

Returns a new vector that is linearly interpolated between start and end using the interpolation amount ratio.

Vector4
max(a: Vector4, b: Vector4)

Returns the maximum of each component of the two vectors.

Vector4
min(a: Vector4, b: Vector4)

Returns the minimum of each component of the two vectors.

Public companion properties

Vector4

Vector with all components set to one.

Vector4

Vector with all components set to zero.

Public constructors

Vector4(other: Vector4)

Creates a new vector with the same values as the other vector.

Vector4(x: Float, y: Float, z: Float, w: Float)

Public functions

Vector4
clamp(min: Vector4, max: Vector4)

Returns a new vector with the each component of this vector clamped between corresponding components of min and max vectors.

Vector4
copy(x: Float, y: Float, z: Float, w: Float)

Returns a copy of the vector.

operator Vector4
div(c: Float)

Returns a new vector with this vector divided by a scalar amount.

operator Vector4
div(other: Vector4)

Returns a new vector with each component of this vector divided by each corresponding component of the other vector.

infix Float
dot(other: Vector4)

Returns the dot product of this vector and the other vector.

open operator Boolean
equals(other: Any?)

Returns true if this vector is equal to the other.

open Int
operator Vector4
minus(other: Vector4)

Returns a new vector with the difference of this vector and the other vector.

operator Vector4
plus(other: Vector4)

Returns a new vector with the sum of this vector and the other vector.

operator Vector4

Get a new vector multiplied by a scalar amount.

operator Vector4
times(other: Vector4)

Returns a new vector with the product of this vector and the other vector.

Vector4

Returns the normalized version of this vector.

open String
operator Vector4

Negates this vector.

Public properties

Float

The length of the vector.

Float

The squared length of the vector.

Float

W component of the vector.

Float

X component of the vector.

Float

Y component of the vector.

Float

Z component of the vector.

Public companion functions

abs

Added in 1.0.0-alpha04
fun abs(vector: Vector4): Vector4

Returns the absolute values of each component of the vector.

angleBetween

Added in 1.0.0-alpha04
fun angleBetween(vector1: Vector4, vector2: Vector4): Float

Returns the angle between this vector and other vector in degrees. The result is never greater than 180 degrees.

distance

Added in 1.0.0-alpha04
fun distance(vector1: Vector4, vector2: Vector4): Float

Returns the distance between this vector and the other vector.

fromValue

Added in 1.0.0-alpha04
fun fromValue(value: Float): Vector4

Creates a new vector with all components set to value.

lerp

Added in 1.0.0-alpha04
fun lerp(start: Vector4, end: Vector4, ratio: Float): Vector4

Returns a new vector that is linearly interpolated between start and end using the interpolation amount ratio.

If ratio is outside of the range [0, 1], the returned vector will be extrapolated.

max

Added in 1.0.0-alpha04
fun max(a: Vector4, b: Vector4): Vector4

Returns the maximum of each component of the two vectors.

min

Added in 1.0.0-alpha04
fun min(a: Vector4, b: Vector4): Vector4

Returns the minimum of each component of the two vectors.

Public companion properties

One

val OneVector4

Vector with all components set to one.

Zero

val ZeroVector4

Vector with all components set to zero.

Public constructors

Vector4

Added in 1.0.0-alpha04
Vector4(other: Vector4)

Creates a new vector with the same values as the other vector.

Vector4

Added in 1.0.0-alpha04
Vector4(x: Float = 0.0f, y: Float = 0.0f, z: Float = 0.0f, w: Float = 0.0f)
Parameters
x: Float = 0.0f

X component of the vector.

y: Float = 0.0f

Y component of the vector.

z: Float = 0.0f

Z component of the vector.

w: Float = 0.0f

W component of the vector.

Public functions

clamp

Added in 1.0.0-alpha04
fun clamp(min: Vector4, max: Vector4): Vector4

Returns a new vector with the each component of this vector clamped between corresponding components of min and max vectors.

copy

Added in 1.0.0-alpha04
fun copy(x: Float = this.x, y: Float = this.y, z: Float = this.z, w: Float = this.w): Vector4

Returns a copy of the vector.

div

Added in 1.0.0-alpha04
operator fun div(c: Float): Vector4

Returns a new vector with this vector divided by a scalar amount.

div

Added in 1.0.0-alpha04
operator fun div(other: Vector4): Vector4

Returns a new vector with each component of this vector divided by each corresponding component of the other vector.

dot

Added in 1.0.0-alpha04
infix fun dot(other: Vector4): Float

Returns the dot product of this vector and the other vector.

equals

open operator fun equals(other: Any?): Boolean

Returns true if this vector is equal to the other.

hashCode

open fun hashCode(): Int

minus

Added in 1.0.0-alpha04
operator fun minus(other: Vector4): Vector4

Returns a new vector with the difference of this vector and the other vector.

plus

Added in 1.0.0-alpha04
operator fun plus(other: Vector4): Vector4

Returns a new vector with the sum of this vector and the other vector.

times

Added in 1.0.0-alpha04
operator fun times(c: Float): Vector4

Get a new vector multiplied by a scalar amount.

times

Added in 1.0.0-alpha04
operator fun times(other: Vector4): Vector4

Returns a new vector with the product of this vector and the other vector.

toNormalized

Added in 1.0.0-alpha04
fun toNormalized(): Vector4

Returns the normalized version of this vector.

toString

open fun toString(): String

unaryMinus

Added in 1.0.0-alpha04
operator fun unaryMinus(): Vector4

Negates this vector.

Public properties

length

Added in 1.0.0-alpha04
val lengthFloat

The length of the vector.

lengthSquared

Added in 1.0.0-alpha04
val lengthSquaredFloat

The squared length of the vector.

w

Added in 1.0.0-alpha04
val wFloat

W component of the vector.

x

Added in 1.0.0-alpha04
val xFloat

X component of the vector.

y

Added in 1.0.0-alpha04
val yFloat

Y component of the vector.

z

Added in 1.0.0-alpha04
val zFloat

Z component of the vector.