API reference
API reference
Select your platform
No SDKs available
No versions available

Vector3

Vector3

data class Vector3(var x: Float, var y: Float, var z: Float)
A 3D vector class.

Constructors

NameSummary
Vector3
constructor(v: Float)
Constructor for creating a Vector3 with all components set to the same value.
constructor(c: <Error class: unknown class>)
Constructor for creating a Vector3 from a Color object.
constructor(x: Float, y: Float, z: Float)

Types

NameSummary
Companion
object Companion

Properties

NameSummary
x
var x: Float
y
var y: Float
z
var z: Float

Functions

NameSummary
add
fun add(v: Vector3): Vector3
Adds two vectors component-wise.
angleBetweenDegrees
fun angleBetweenDegrees(v: Vector3): Float
Calculates the angle between two vectors in degrees.
cross
fun cross(other: Vector3): Vector3
Calculates the cross product of two vectors.
distanceTo
fun distanceTo(v: Vector3): Float
Calculates the distance between two vectors.
div
operator fun div(v: Float): Vector3
Divides a vector by a scalar.
divide
fun divide(v: Float): Vector3
Divides a vector by a scalar.
dot
fun dot(v: Vector3): Float
Calculates the dot product of two vectors.
length
fun length(): Float
Calculates the length (magnitude) of a vector.
lerp
fun lerp(dest: Vector3, ratio: Float): Vector3
Linearly interpolates between two vectors.
minus
operator fun minus(v: Vector3): Vector3
Subtracts two vectors component-wise.
multiply
fun multiply(v: Vector3): Vector3
Multiplies two vectors component-wise.
fun multiply(v: Float): Vector3
Multiplies a vector by a scalar.
negate
fun negate(): Vector3
Negates a vector.
normalize
fun normalize(): Vector3
Normalizes a vector to have a length of 1
plus
operator fun plus(v: Vector3): Vector3
Adds two vectors component-wise.
setX
fun setX(x: Float): Vector3
setY
fun setY(y: Float): Vector3
setZ
fun setZ(z: Float): Vector3
sub
fun sub(v: Vector3): Vector3
Subtracts two vectors component-wise.
times
operator fun times(v: Vector3): Vector3
Multiplies two vectors component-wise.
operator fun times(v: Float): Vector3
Multiplies a vector by a scalar.
toString
open override fun toString(): String
Returns a string representation of the vector.
unaryMinus
operator fun unaryMinus(): Vector3
Negates a vector.

Companion

object Companion

Properties

NameSummary
Forward
val Forward: Vector3
Right
val Right: Vector3
Up
val Up: Vector3
Did you find this page helpful?
Thumbs up icon
Thumbs down icon