open class Vector2(var x: Float = 0.0f, var y: Float = 0.0f)
Vector2
(
v
)
|
Secondary constructor to create a vector where both components are the same.
Signature
constructor(v: Float) Parameters v: Float
The value to use for both components.
Returns Vector2 |
Vector2
(
x
, y
)
|
Signature
constructor(x: Float = 0.0f, y: Float = 0.0f) Parameters x: Float
The x coordinate component. Defaults to 0f.
y: Float
The y coordinate component. Defaults to 0f.
Returns Vector2 |
x
: Float
[Get][Set] |
The x coordinate component. Defaults to 0f.
Signature
open var x: Float |
y
: Float
[Get][Set] |
The y coordinate component. Defaults to 0f.
Signature
open var y: Float |
add
(
v
)
| |
component1
()
|
Signature
operator fun component1(): Float Returns Float |
component2
()
|
Signature
operator fun component2(): Float Returns Float |
copy
()
| |
cross
(
other
)
|
Calculates the cross product of this vector with another vector.
Signature
fun cross(other: Vector2): Float Parameters Returns Float
The cross product of this vector and the other vector.
|
distanceTo
(
v
)
|
Calculates the distance to another vector.
Signature
fun distanceTo(v: Vector2): Float Parameters Returns Float
The distance between this vector and the other vector.
|
div
(
v
)
|
Divides each component of this vector by a scalar.
Signature
operator fun div(v: Float): Vector2 Parameters v: Float
The scalar to divide by.
|
divide
(
v
)
|
Divides each component of this vector by a scalar.
Signature
fun divide(v: Float): Vector2 Parameters v: Float
The scalar to divide by.
|
dot
(
v
)
|
Calculates the dot product of this vector with another vector.
Signature
fun dot(v: Vector2): Float Parameters Returns Float
The dot product of this vector and the other vector.
|
equals
(
other
)
|
Signature
open operator override fun equals(other: Any?): Boolean Parameters other: Any?Returns Boolean |
hashCode
()
|
Signature
open override fun hashCode(): Int Returns Int |
length
()
|
Returns the length (magnitude) of this vector.
Signature
fun length(): Float Returns Float
The length of this vector.
|
lerp
(
dest
, ratio
)
|
Linearly interpolates between this vector and another vector by the given ratio.
Signature
fun lerp(dest: Vector2, ratio: Float): Vector2 Parameters 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 Vector2
A new vector representing the linear interpolation between this vector and the destination vector by the given ratio.
|
max
(
v
)
| |
min
(
v
)
| |
minus
(
v
)
| |
multiply
(
v
)
| |
multiply
(
v
)
|
Multiplies each component of this vector by a scalar.
Signature
fun multiply(v: Float): Vector2 Parameters v: Float
The scalar to multiply by.
|
negate
()
|
Negates this vector.
Signature
fun negate(): Vector2 |
normalize
()
|
Normalizes this vector.
Signature
fun normalize(): Vector2 Returns Vector2
A new vector representing the normalization of this vector, or (0, 0) if the length of this vector is 0.
|
plus
(
v
)
| |
setX
(
x
)
|
Sets the x component of this vector.
Signature
fun setX(x: Float): Vector2 Parameters x: Float
The new value for the x component.
|
setY
(
y
)
|
Sets the y component of this vector.
Signature
fun setY(y: Float): Vector2 Parameters y: Float
The new value for the y component.
|
sub
(
v
)
| |
times
(
v
)
| |
times
(
v
)
|
Multiplies each component of this vector by a scalar.
Signature
operator fun times(v: Float): Vector2 Parameters v: Float
The scalar to multiply by.
|
toString
()
|
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)".
|
unaryMinus
()
|
Negates this vector.
Signature
operator fun unaryMinus(): Vector2 |