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

Vector3

Vector3

open 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
open var x: Float
y
open var y: Float
z
open var z: Float

Functions

NameSummary
add
inline fun add(v: Vector3): Vector3
Adds two vectors component-wise.
angleBetweenDegrees
fun angleBetweenDegrees(v: Vector3): Float
Calculates the angle between two vectors in degrees.
component1
operator fun component1(): Float
component2
operator fun component2(): Float
component3
operator fun component3(): Float
copy
fun copy(): Vector3
Returns a copy of this vector.
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
inline operator fun div(v: Float): Vector3
Divides a vector by a scalar.
divide
inline fun divide(v: Float): Vector3
Divides a vector by a scalar.
dot
inline fun dot(v: Vector3): Float
Calculates the dot product of two vectors.
equals
open operator override fun equals(other: Any?): Boolean
hashCode
open override fun hashCode(): Int
length
fun length(): Float
Calculates the length (magnitude) of a vector.
lerp
fun lerp(dest: Vector3, ratio: Float): Vector3
Linearly interpolates between two vectors.
max
fun max(v: Vector3): Vector3
Returns a vector with the maximum components of this vector and another vector.
min
fun min(v: Vector3): Vector3
Returns a vector with the minimum components of this vector and another vector.
minus
inline operator fun minus(v: Vector3): Vector3
Subtracts two vectors component-wise.
multiply
inline fun multiply(v: Vector3): Vector3
Multiplies two vectors component-wise.
inline fun multiply(v: Float): Vector3
Multiplies a vector by a scalar.
negate
inline fun negate(): Vector3
Negates a vector.
normalize
fun normalize(): Vector3
Normalizes a vector to have a length of 1
plus
inline 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
inline fun sub(v: Vector3): Vector3
Subtracts two vectors component-wise.
times
inline operator fun times(v: Vector3): Vector3
Multiplies two vectors component-wise.
inline 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
inline 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