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

Vector3 Class

Modifiers: open
A 3D vector class.

Signature

open class Vector3(var x: Float, var y: Float, var z: Float)

Constructors

Vector3 ( v ) : Vector3
Constructor for creating a Vector3 with all components set to the same value.
Signature
constructor(v: Float)
Parameters
v: Float
The value to set for all components.
Returns
Vector3 ( c ) : Vector3
Constructor for creating a Vector3 from a Color object.
Signature
constructor(c: Color)
Parameters
c: Color
The Color object to create the Vector3 from.
Returns
Vector3 ( x , y , z ) : Vector3
Signature
constructor(x: Float, y: Float, z: Float)
Parameters
x: Float
y: Float
z: Float
Returns

Properties

x : Float
[Get][Set]
Signature
open var x: Float
y : Float
[Get][Set]
Signature
open var y: Float
z : Float
[Get][Set]
Signature
open var z: Float

Functions

add ( v ) : Vector3
Adds two vectors component-wise.
Signature
inline fun add(v: Vector3): Vector3
Parameters
The vector to add.
Returns
The resulting vector.
angleBetweenDegrees ( v ) : Float
Calculates the angle between two vectors in degrees.
Signature
fun angleBetweenDegrees(v: Vector3): Float
Parameters
The other vector to calculate the angle with.
Returns
Float
The angle between the two vectors in degrees.
component1 () : Float
Signature
operator fun component1(): Float
Returns
Float
component2 () : Float
Signature
operator fun component2(): Float
Returns
Float
component3 () : Float
Signature
operator fun component3(): Float
Returns
Float
copy () : Vector3
Returns a copy of this vector.
Signature
fun copy(): Vector3
Returns
A copy of this vector.
cross ( other ) : Vector3
Calculates the cross product of two vectors.
Signature
fun cross(other: Vector3): Vector3
Parameters
other: Vector3
The vector to calculate the cross product with.
Returns
The cross product.
distanceTo ( v ) : Float
Calculates the distance between two vectors.
Signature
fun distanceTo(v: Vector3): Float
Parameters
The other vector to calculate the distance to.
Returns
Float
The distance between the two vectors.
div ( v ) : Vector3
Divides a vector by a scalar.
Signature
inline operator fun div(v: Float): Vector3
Parameters
v: Float
The scalar to divide by.
Returns
The resulting vector.
divide ( v ) : Vector3
Divides a vector by a scalar.
Signature
inline fun divide(v: Float): Vector3
Parameters
v: Float
The scalar to divide by.
Returns
The resulting vector.
dot ( v ) : Float
Calculates the dot product of two vectors.
Signature
inline fun dot(v: Vector3): Float
Parameters
The vector to calculate the dot product with.
Returns
Float
The dot product.
equals ( other ) : Boolean
Signature
open operator override fun equals(other: Any?): Boolean
Parameters
other: Any?
Returns
Boolean
hashCode () : Int
Signature
open override fun hashCode(): Int
Returns
Int
length () : Float
Calculates the length (magnitude) of a vector.
Signature
fun length(): Float
Returns
Float
The length of the vector.
lerp ( dest , ratio ) : Vector3
Linearly interpolates between two vectors.
Signature
fun lerp(dest: Vector3, ratio: Float): Vector3
Parameters
dest: Vector3
The destination vector to interpolate towards.
ratio: Float
The interpolation ratio, where 0 means no interpolation (i.e., the current vector) and 1 means full interpolation (i.e., the destination vector).
Returns
The interpolated vector.
max ( v ) : Vector3
Returns a vector with the maximum components of this vector and another vector.
Signature
fun max(v: Vector3): Vector3
Parameters
The other vector to compare with.
Returns
A new vector with the maximum components.
min ( v ) : Vector3
Returns a vector with the minimum components of this vector and another vector.
Signature
fun min(v: Vector3): Vector3
Parameters
The other vector to compare with.
Returns
A new vector with the minimum components.
minus ( v ) : Vector3
Subtracts two vectors component-wise.
Signature
inline operator fun minus(v: Vector3): Vector3
Parameters
The vector to subtract.
Returns
The resulting vector.
multiply ( v ) : Vector3
Multiplies two vectors component-wise.
Signature
inline fun multiply(v: Vector3): Vector3
Parameters
The vector to multiply.
Returns
The resulting vector.
multiply ( v ) : Vector3
Multiplies a vector by a scalar.
Signature
inline fun multiply(v: Float): Vector3
Parameters
v: Float
The scalar to multiply.
Returns
The resulting vector.
negate () : Vector3
Negates a vector.
Signature
inline fun negate(): Vector3
Returns
The negated vector.
normalize () : Vector3
Normalizes a vector to have a length of 1
Signature
fun normalize(): Vector3
Returns
A new vector representing the normalization of this vector, or (0, 0, 0) if the length of this vector is 0.
plus ( v ) : Vector3
Adds two vectors component-wise.
Signature
inline operator fun plus(v: Vector3): Vector3
Parameters
The vector to add.
Returns
The resulting vector.
setX ( x ) : Vector3
Signature
fun setX(x: Float): Vector3
Parameters
x: Float
Returns
setY ( y ) : Vector3
Signature
fun setY(y: Float): Vector3
Parameters
y: Float
Returns
setZ ( z ) : Vector3
Signature
fun setZ(z: Float): Vector3
Parameters
z: Float
Returns
sub ( v ) : Vector3
Subtracts two vectors component-wise.
Signature
inline fun sub(v: Vector3): Vector3
Parameters
The vector to subtract.
Returns
The resulting vector.
times ( v ) : Vector3
Multiplies two vectors component-wise.
Signature
inline operator fun times(v: Vector3): Vector3
Parameters
The vector to multiply.
Returns
The resulting vector.
times ( v ) : Vector3
Multiplies a vector by a scalar.
Signature
inline operator fun times(v: Float): Vector3
Parameters
v: Float
The scalar to multiply.
Returns
The resulting vector.
toString () : String
Returns a string representation of the vector.
Signature
open override fun toString(): String
Returns
String
A string representation of the vector in the format "(x, y, z)".
unaryMinus () : Vector3
Negates a vector.
Signature
inline operator fun unaryMinus(): Vector3
Returns
The negated vector.

Companion Object

Companion Object Properties

Forward : Vector3
[Get]
Signature
val Forward: Vector3
Right : Vector3
[Get]
Signature
val Right: Vector3
Up : Vector3
[Get]
Signature
val Up: Vector3
Did you find this page helpful?
Thumbs up icon
Thumbs down icon