Vector4
class Vector4
Represents a four-dimensional position in space.
Summary
Public companion functions |
|
|---|---|
Vector4 |
Returns the absolute values of each component of the vector. |
Float |
angleBetween(vector1: Vector4, vector2: Vector4)Returns the angle between this vector and other vector in degrees. |
Float |
Returns the distance between this vector and the other vector. |
Vector4 |
Creates a new vector with all components set to |
Vector4 |
Returns a new vector that is linearly interpolated between |
Vector4 |
Returns the maximum of each component of the two vectors. |
Vector4 |
Returns the minimum of each component of the two vectors. |
Public companion properties |
|
|---|---|
Vector4 |
Vector with all components set to one. |
Vector4 |
Vector with all components set to zero. |
Public constructors |
|---|
|
Creates a new vector with the same values as the |
Public functions |
|
|---|---|
Vector4 |
Returns a new vector with the each component of this vector clamped between corresponding components of |
Vector4 |
Returns a copy of the vector. |
operator Vector4 |
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 the |
open Int |
hashCode() |
Vector4 |
inverse()Returns the component-wise multiplicative inverse of this vector. |
operator Vector4 |
Returns a new vector with the difference of this vector and the |
operator Vector4 |
Returns a new vector with the sum of this vector and the |
Vector4 |
Returns a new vector with each component of this vector multiplied by each corresponding component of the |
operator Vector4 |
Get a new vector multiplied by a scalar amount. |
Vector4 |
Returns the normalized version of this vector. |
open String |
toString() |
operator Vector4 |
Negates this vector. |
Public properties |
|
|---|---|
Float |
The length of the vector. |
Float |
The squared length of the vector. |
Float |
W component of the vector. |
Float |
X component of the vector. |
Float |
Y component of the vector. |
Float |
Z component of the vector. |
Public companion functions
abs
fun abs(vector: Vector4): Vector4
Returns the absolute values of each component of the vector.
angleBetween
fun angleBetween(vector1: Vector4, vector2: Vector4): Float
Returns the angle between this vector and other vector in degrees. The result is never greater than 180 degrees.
distance
fun distance(vector1: Vector4, vector2: Vector4): Float
Returns the distance between this vector and the other vector.
fromValue
fun fromValue(value: Float): Vector4
Creates a new vector with all components set to value.
lerp
fun lerp(start: Vector4, end: Vector4, ratio: Float): Vector4
Returns a new vector that is linearly interpolated between start and end using the interpolation amount ratio.
If ratio is outside of the range [0, 1], the returned vector will be extrapolated.
max
fun max(a: Vector4, b: Vector4): Vector4
Returns the maximum of each component of the two vectors.
min
fun min(a: Vector4, b: Vector4): Vector4
Returns the minimum of each component of the two vectors.
Public companion properties
Public constructors
Vector4
Vector4(other: Vector4)
Creates a new vector with the same values as the other vector.
Public functions
clamp
fun clamp(min: Vector4, max: Vector4): Vector4
Returns a new vector with the each component of this vector clamped between corresponding components of min and max vectors.
copy
fun copy(x: Float = this.x, y: Float = this.y, z: Float = this.z, w: Float = this.w): Vector4
Returns a copy of the vector.
div
operator fun div(c: Float): Vector4
Returns a new vector with this vector divided by a scalar amount.
dot
infix fun dot(other: Vector4): 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 the other.
inverse
fun inverse(): Vector4
Returns the component-wise multiplicative inverse of this vector.
minus
operator fun minus(other: Vector4): Vector4
Returns a new vector with the difference of this vector and the other vector.
plus
operator fun plus(other: Vector4): Vector4
Returns a new vector with the sum of this vector and the other vector.
scale
fun scale(other: Vector4): Vector4
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): Vector4
Get a new vector multiplied by a scalar amount.
toNormalized
fun toNormalized(): Vector4
Returns the normalized version of this vector.