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
Returns |
Vector2
(
x
, y
)
|
Signature
constructor(x: Float = 0.0f, y: Float = 0.0f) Parameters
x:
Float
y:
Float
Returns |
x
: Float
[Get][Set] |
Signature
open var x: Float |
y
: Float
[Get][Set] |
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
|
distanceTo
(
v
)
|
Calculates the distance to another vector.
Signature
fun distanceTo(v: Vector2): Float Parameters Returns
Float
|
div
(
v
)
|
Divides each component of this vector by a scalar.
Signature
operator fun div(v: Float): Vector2 Parameters
v:
Float
|
divide
(
v
)
|
Divides each component of this vector by a scalar.
Signature
fun divide(v: Float): Vector2 Parameters
v:
Float
|
dot
(
v
)
|
Calculates the dot product of this vector with another vector.
Signature
fun dot(v: Vector2): Float Parameters Returns
Float
|
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
|
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
Returns
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
|
negate
()
|
Negates this vector.
Signature
fun negate(): Vector2 |
normalize
()
|
Normalizes this vector.
Signature
fun normalize(): Vector2 Returns
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
|
setY
(
y
)
|
Sets the y component of this vector.
Signature
fun setY(y: Float): Vector2 Parameters
y:
Float
|
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
|
toString
()
|
Returns a string representation of the vector.
Signature
open override fun toString(): String Returns
String
|
unaryMinus
()
|
Negates this vector.
Signature
operator fun unaryMinus(): Vector2 |