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

Float
distance(vector1: Vector3, vector2: Vector3)

Returns the distance between vector1 and vector2.

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.

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
Vector3

Returns the component-wise multiplicative inverse of this vector.

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.

Vector3
scale(other: Vector3)

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

operator Vector3

Get a new vector multiplied by a scalar amount.

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-alpha10
fun abs(vector: Vector3): Vector3

Returns the absolute values of each component of the vector.

Parameters
vector: Vector3

the vector to get the absolute values of

angleBetween

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

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

Parameters
vector1: Vector3

the first vector

vector2: Vector3

the second vector

distance

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

Returns the distance between vector1 and vector2.

Parameters
vector1: Vector3

the first vector

vector2: Vector3

the second vector

fromValue

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

Creates a new vector with all components set to value.

lerp

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

Parameters
start: Vector3

the starting vector

end: Vector3

the ending vector

ratio: Float

the interpolation ratio

max

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

Returns the maximum of each component of the two vectors.

Parameters
a: Vector3

the first vector

b: Vector3

the second vector

min

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

Returns the minimum of each component of the two vectors.

Parameters
a: Vector3

the first vector

b: Vector3

the second vector

projectOnPlane

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

Computes the vector projected from vector onto planeNormal.

Parameters
vector: Vector3

the vector to project

planeNormal: Vector3

the normal of the plane to project onto

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

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

Vector3

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

Public functions

clamp

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

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

Parameters
min: Vector3

the minimum clamp values

max: Vector3

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): Vector3

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

cross

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

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

div

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

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: 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

inverse

Added in 1.0.0-alpha10
fun inverse(): Vector3

Returns the component-wise multiplicative inverse of this vector.

minus

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

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

scale

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

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): Vector3

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(): Vector3

Returns the normalized version of this vector.

toString

open fun toString(): String

unaryMinus

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

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.

x

Added in 1.0.0-alpha10
val xFloat

the value of the horizontal component

y

Added in 1.0.0-alpha10
val yFloat

the value of the vertical component

z

Added in 1.0.0-alpha10
val zFloat

the value of the forward component