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 vector1 and vector2 in degrees.

Float
distance(vector1: Vector4, vector2: Vector4)

Returns the distance between vector1 and vector2.

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.

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
Vector4

Returns the component-wise multiplicative inverse of this vector.

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.

Vector4
scale(other: Vector4)

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

operator Vector4

Get a new vector multiplied by a scalar amount.

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

the w component of the vector

Float

the x component of the vector

Float

the y component of the vector

Float

the z component of the vector

Public companion functions

abs

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

Returns the absolute values of each component of the vector.

Parameters
vector: Vector4

the vector to get the absolute values of

angleBetween

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

Returns the angle between vector1 and vector2 in degrees. The result is never greater than 180 degrees.

Parameters
vector1: Vector4

the first vector

vector2: Vector4

the second vector

distance

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

Returns the distance between vector1 and vector2.

Parameters
vector1: Vector4

the first vector

vector2: Vector4

the second vector

fromValue

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

Creates a new vector with all components set to value.

lerp

Added in 1.0.0-alpha10
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.

Parameters
start: Vector4

the starting vector

end: Vector4

the ending vector

ratio: Float

the interpolation ratio

max

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

Returns the maximum of each component of the two vectors.

Parameters
a: Vector4

the first vector

b: Vector4

the second vector

min

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

Returns the minimum of each component of the two vectors.

Parameters
a: Vector4

the first vector

b: Vector4

the second vector

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-alpha10
Vector4(other: Vector4)

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

Vector4

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

Public functions

clamp

Added in 1.0.0-alpha10
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.

Parameters
min: Vector4

the minimum clamp values

max: Vector4

the maximum clamp values

copy

Added in 1.0.0-alpha10
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.

Parameters
x: Float = this.x

the new x value for the copied vector

y: Float = this.y

the new y value for the copied vector

z: Float = this.z

the new z value for the copied vector

w: Float = this.w

the new w value for the copied vector

div

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

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

Parameters
c: Float

the scalar to divide by

dot

Added in 1.0.0-alpha10
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

inverse

Added in 1.0.0-alpha10
fun inverse(): Vector4

Returns the component-wise multiplicative inverse of this vector.

minus

Added in 1.0.0-alpha10
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-alpha10
operator fun plus(other: Vector4): Vector4

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

scale

Added in 1.0.0-alpha10
fun scale(other: Vector4): Vector4

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

times

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

Get a new vector multiplied by a scalar amount.

Parameters
c: Float

the scalar to multiply by

toNormalized

Added in 1.0.0-alpha10
fun toNormalized(): Vector4

Returns the normalized version of this vector.

toString

open fun toString(): String

unaryMinus

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

Negates this vector.

Public properties

length

Added in 1.0.0-alpha10
val lengthFloat

The length of the vector.

lengthSquared

Added in 1.0.0-alpha10
val lengthSquaredFloat

The squared length of the vector.

w

Added in 1.0.0-alpha10
val wFloat

the w component of the vector

x

Added in 1.0.0-alpha10
val xFloat

the x component of the vector

y

Added in 1.0.0-alpha10
val yFloat

the y component of the vector

z

Added in 1.0.0-alpha10
val zFloat

the z component of the vector