Vector2
class Vector2
Represents a position in the 2D plane.
Summary
Public companion functions |
|
|---|---|
Vector2 |
Returns the absolute values of each component of the vector. |
Float |
angularDistance(vector1: Vector2, vector2: Vector2)Returns the angle between this vector and the other vector. |
Float |
Returns the distance between this vector and the other vector. |
Vector2 |
Returns a new vector that is linearly interpolated between |
Public companion properties |
|
|---|---|
Vector2 |
Vector with y set to negative one and all other components set to zero. |
Vector2 |
Vector with x set to negative one and all other components set to zero. |
Vector2 |
Vector with all components set to one. |
Vector2 |
Vector with x set to one and all other components set to zero. |
Vector2 |
Vector with y set to one and all other components set to zero. |
Vector2 |
Vector with all components set to zero. |
Public constructors |
|---|
|
Creates a new vector with the same values as the |
Public functions |
|
|---|---|
Vector2 |
Returns a new vector with the values clamped between |
inline Vector2 |
Returns a copy of the vector. |
inline infix Float |
Returns the cross product of this vector and the |
inline operator Vector2 |
Returns a new vector with this vector divided by a scalar amount. |
inline 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() |
Vector2 |
inverse()Returns the component-wise multiplicative inverse of this vector. |
inline operator Vector2 |
Returns a new vector with the difference of this vector and the |
operator Vector2 |
Returns a new vector with the sum of this vector and the |
inline Vector2 |
Returns a new vector with each component of this vector multiplied by each corresponding component of the |
inline operator Vector2 |
Returns a new vector multiplied by a scalar amount |
Vector2 |
Returns a normalized version of this vector. |
open String |
toString() |
inline operator Vector2 |
Negates the values of this vector. |
Public properties |
|
|---|---|
Float |
The length of the vector. |
Float |
The squared length of the vector. |
Float |
X component of the vector. |
Float |
Y component of the vector. |
Public companion functions
abs
fun abs(vector: Vector2): Vector2
Returns the absolute values of each component of the vector.
angularDistance
fun angularDistance(vector1: Vector2, vector2: Vector2): Float
Returns the angle between this vector and the other vector.
distance
fun distance(vector1: Vector2, vector2: Vector2): Float
Returns the distance between this vector and the other vector.
Public companion properties
Public constructors
Vector2
Vector2(other: Vector2)
Creates a new vector with the same values as the other vector.
Public functions
clamp
fun clamp(min: Vector2, max: Vector2): Vector2
Returns a new vector with the values clamped between min and max vectors.
copy
inline fun copy(x: Float = this.x, y: Float = this.y): Vector2
Returns a copy of the vector.
cross
inline infix fun cross(other: Vector2): Float
Returns the cross product of this vector and the other vector.
div
inline operator fun div(c: Float): Vector2
Returns a new vector with this vector divided by a scalar amount.
dot
inline infix fun dot(other: Vector2): 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(): Vector2
Returns the component-wise multiplicative inverse of this vector.
minus
inline operator fun minus(other: Vector2): Vector2
Returns a new vector with the difference of this vector and the other vector.
plus
operator fun plus(other: Vector2): Vector2
Returns a new vector with the sum of this vector and the other vector.
scale
inline fun scale(other: Vector2): Vector2
Returns a new vector with each component of this vector multiplied by each corresponding component of the other vector.
times
inline operator fun times(c: Float): Vector2
Returns a new vector multiplied by a scalar amount
toNormalized
fun toNormalized(): Vector2
Returns a normalized version of this vector.
unaryMinus
inline operator fun unaryMinus(): Vector2
Negates the values of this vector.