Vector3
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 |
Returns the absolute values of each component of the vector. |
Float |
angleBetween(vector1: Vector3, vector2: Vector3) |
Float |
|
Vector3 |
Creates a new vector with all components set to |
Vector3 |
Returns a new vector that is linearly interpolated between |
Vector3 |
Returns the maximum of each component of the two vectors. |
Vector3 |
Returns the minimum of each component of the two vectors. |
Vector3 |
projectOnPlane(vector: Vector3, planeNormal: Vector3)Computes the vector projected from |
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 |
|---|
|
Creates a new vector with the same values as the |
Public functions |
|
|---|---|
Vector3 |
Returns a new vector with its values clamped between |
Vector3 |
Returns a copy of the vector. |
infix Vector3 |
Returns the cross product of this vector and the |
operator Vector3 |
Returns a new vector with this vector divided by a scalar amount. |
infix Float |
Returns the dot product of this vector and the |
open operator Boolean |
Returns true if this vector is equal to |
open Int |
hashCode() |
Vector3 |
inverse()Returns the component-wise multiplicative inverse of this vector. |
operator Vector3 |
Returns a new vector with the difference of this vector and the |
operator Vector3 |
Returns a new vector with the sum of this vector and the |
Vector3 |
Returns a new vector with each component of this vector multiplied by each corresponding component of the |
operator Vector3 |
Get a new vector multiplied by a scalar amount. |
Vector3 |
Returns the normalized version of this vector. |
open String |
toString() |
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
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
fun angleBetween(vector1: Vector3, vector2: Vector3): Float
Returns the angle between vector1 and vector2 in degrees. The result is never greater than 180 degrees.
fromValue
fun fromValue(value: Float): Vector3
Creates a new vector with all components set to value.
lerp
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
fun max(a: Vector3, b: Vector3): Vector3
Returns the maximum of each component of the two vectors.
min
fun min(a: Vector3, b: Vector3): Vector3
Returns the minimum of each component of the two vectors.
projectOnPlane
fun projectOnPlane(vector: Vector3, planeNormal: Vector3): Vector3
Computes the vector projected from vector onto planeNormal.
Public companion properties
Public constructors
Vector3
Vector3(other: Vector3)
Creates a new vector with the same values as the other vector.
Public functions
clamp
fun clamp(min: Vector3, max: Vector3): Vector3
Returns a new vector with its values clamped between min and max vectors.
copy
fun copy(x: Float = this.x, y: Float = this.y, z: Float = this.z): Vector3
Returns a copy of the vector.
cross
infix fun cross(other: Vector3): Vector3
Returns the cross product of this vector and the other vector.
div
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
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.
inverse
fun inverse(): Vector3
Returns the component-wise multiplicative inverse of this vector.
minus
operator fun minus(other: Vector3): Vector3
Returns a new vector with the difference of this vector and the other vector.
plus
operator fun plus(other: Vector3): Vector3
Returns a new vector with the sum of this vector and the other vector.
scale
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
operator fun times(c: Float): Vector3
Get a new vector multiplied by a scalar amount.
| Parameters | |
|---|---|
c: Float |
the scalar to multiply by |
toNormalized
fun toNormalized(): Vector3
Returns the normalized version of this vector. A zero-length vector has no direction to normalize and returns Zero rather than a vector of NaN components.