class Vector3


Represents a three-dimensional position in space.

The coordinate system is right-handed. The x-axis points to the right, the y-axis up and the z-axis back.

Summary

Public companion functions

Vector3
abs(vector: Vector3)

Returns the absolute values of each component of the vector.

Float
angleBetween(vector1: Vector3, vector2: Vector3)

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

Float
distance(vector1: Vector3, vector2: Vector3)

Returns the distance between this vector and the other vector.

Vector3
fromValue(value: Float)

Creates a new vector with all components set to value.

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

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

Vector3
max(a: Vector3, b: Vector3)

Returns the maximum of each component of the two vectors.

Vector3
min(a: Vector3, b: Vector3)

Returns the minimum of each component of the two vectors.

Vector3
projectOnPlane(vector: Vector3, planeNormal: Vector3)

Computes the vector projected from vector onto planeNormal.

Public companion properties

Vector3

Vector with z set to one and all other components set to zero.

Vector3

Vector with y set to negative one and all other components set to zero.

Vector3

Vector with z set to negative one and all other components set to zero.

Vector3

Vector with x set to negative one and all other components set to zero.

Vector3

Vector with all components set to one.

Vector3

Vector with x set to one and all other components set to zero.

Vector3

Vector with y set to one and all other components set to zero.

Vector3

Vector with all components set to zero.

Public constructors

Vector3(other: Vector3)

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

Vector3(x: Float, y: Float, z: Float)

Public functions

Vector3
clamp(min: Vector3, max: Vector3)

Returns a new vector with its values clamped between min and max vectors.

Vector3
copy(x: Float, y: Float, z: Float)

Returns a copy of the vector.

infix Vector3
cross(other: Vector3)

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

operator Vector3
div(c: Float)

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

operator Vector3
div(other: Vector3)

Returns a new vector with this vector divided by the other vector.

infix Float
dot(other: Vector3)

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

open Int
operator Vector3
minus(other: Vector3)

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

operator Vector3
plus(other: Vector3)

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

operator Vector3

Get a new vector multiplied by a scalar amount.

operator Vector3
times(other: Vector3)

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

Vector3

Returns the normalized version of this vector.

open String
operator Vector3

Negates this vector.

Public properties

Float

The length of the vector.

Float

The squared length of the vector.

Float

the value of the horizontal component.

Float

the value of the vertical component.

Float

the value of the forward component.

Public companion functions

abs

Added in 1.0.0-alpha01
fun abs(vector: Vector3): Vector3

Returns the absolute values of each component of the vector.

angleBetween

Added in 1.0.0-alpha01
fun angleBetween(vector1: Vector3, vector2: Vector3): Float

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

distance

Added in 1.0.0-alpha01
fun distance(vector1: Vector3, vector2: Vector3): Float

Returns the distance between this vector and the other vector.

fromValue

Added in 1.0.0-alpha01
fun fromValue(value: Float): Vector3

Creates a new vector with all components set to value.

lerp

Added in 1.0.0-alpha01
fun lerp(start: Vector3, end: Vector3, ratio: Float): Vector3

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

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

max

Added in 1.0.0-alpha01
fun max(a: Vector3, b: Vector3): Vector3

Returns the maximum of each component of the two vectors.

min

Added in 1.0.0-alpha01
fun min(a: Vector3, b: Vector3): Vector3

Returns the minimum of each component of the two vectors.

projectOnPlane

Added in 1.0.0-alpha01
fun projectOnPlane(vector: Vector3, planeNormal: Vector3): Vector3

Computes the vector projected from vector onto planeNormal.

Public companion properties

Backward

val BackwardVector3

Vector with z set to one and all other components set to zero.

Down

val DownVector3

Vector with y set to negative one and all other components set to zero.

Forward

val ForwardVector3

Vector with z set to negative one and all other components set to zero.

Left

val LeftVector3

Vector with x set to negative one and all other components set to zero.

One

val OneVector3

Vector with all components set to one.

Right

val RightVector3

Vector with x set to one and all other components set to zero.

Up

val UpVector3

Vector with y set to one and all other components set to zero.

Zero

val ZeroVector3

Vector with all components set to zero.

Public constructors

Vector3

Added in 1.0.0-alpha01
Vector3(other: Vector3)

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

Vector3

Added in 1.0.0-alpha01
Vector3(x: Float = 0.0f, y: Float = 0.0f, z: Float = 0.0f)

Public functions

clamp

Added in 1.0.0-alpha01
fun clamp(min: Vector3, max: Vector3): Vector3

Returns a new vector with its values clamped between min and max vectors.

copy

Added in 1.0.0-alpha01
fun copy(x: Float = this.x, y: Float = this.y, z: Float = this.z): Vector3

Returns a copy of the vector.

cross

Added in 1.0.0-alpha01
infix fun cross(other: Vector3): Vector3

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

div

Added in 1.0.0-alpha01
operator fun div(c: Float): Vector3

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

div

Added in 1.0.0-alpha01
operator fun div(other: Vector3): Vector3

Returns a new vector with this vector divided by the other vector.

dot

Added in 1.0.0-alpha01
infix fun dot(other: Vector3): 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 other.

hashCode

open fun hashCode(): Int

minus

Added in 1.0.0-alpha01
operator fun minus(other: Vector3): Vector3

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

plus

Added in 1.0.0-alpha01
operator fun plus(other: Vector3): Vector3

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

times

Added in 1.0.0-alpha01
operator fun times(c: Float): Vector3

Get a new vector multiplied by a scalar amount.

times

Added in 1.0.0-alpha01
operator fun times(other: Vector3): Vector3

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

toNormalized

Added in 1.0.0-alpha01
fun toNormalized(): Vector3

Returns the normalized version of this vector.

toString

open fun toString(): String

unaryMinus

Added in 1.0.0-alpha01
operator fun unaryMinus(): Vector3

Negates this vector.

Public properties

length

Added in 1.0.0-alpha01
val lengthFloat

The length of the vector.

lengthSquared

Added in 1.0.0-alpha01
val lengthSquaredFloat

The squared length of the vector.

x

Added in 1.0.0-alpha01
val xFloat

the value of the horizontal component.

y

Added in 1.0.0-alpha01
val yFloat

the value of the vertical component.

z

Added in 1.0.0-alpha01
val zFloat

the value of the forward component.