Vector2

data class Vector2(x: Double, y: Double) : LinearType<Vector2>

Double-precision 2D vector.

Constructors

Vector2
Link copied to clipboard
fun Vector2(x: Double)
Vector2
Link copied to clipboard
fun Vector2(x: Double, y: Double)

Types

Companion
Link copied to clipboard
object Companion

Functions

cross
Link copied to clipboard
infix fun cross(right: Vector2): Double

Calculates a cross product between this Vector2 and right.

distanceTo
Link copied to clipboard
fun distanceTo(other: Vector2): Double

Calculates the Euclidean distance to other.

div
Link copied to clipboard
open operator override fun div(scale: Double): Vector2
operator fun div(d: Vector2): Vector2
dot
Link copied to clipboard
infix fun dot(right: Vector2): Double

Calculates a dot product between this Vector2 and right.

get
Link copied to clipboard
operator fun get(i: Int): Double
minus
Link copied to clipboard
operator fun minus(d: Double): Vector2
open operator override fun minus(right: Vector2): Vector2
mix
Link copied to clipboard
fun mix(o: Vector2, mix: Double): Vector2
perpendicular
Link copied to clipboard
fun perpendicular(polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Vector2

Calculates a vector perpendicular to the current one.

plus
Link copied to clipboard
operator fun plus(d: Double): Vector2
open operator override fun plus(right: Vector2): Vector2
reflect
Link copied to clipboard
infix fun reflect(surfaceNormal: Vector2): Vector2
rotate
Link copied to clipboard
fun rotate(degrees: Double, origin: Vector2 = ZERO): Vector2

Creates a new Vector2 with the given rotation and origin.

squaredDistanceTo
Link copied to clipboard
fun squaredDistanceTo(other: Vector2): Double

Calculates the squared Euclidean distance to other.

times
Link copied to clipboard
open operator override fun times(scale: Double): Vector2
operator fun times(v: Vector2): Vector2
toDoubleArray
Link copied to clipboard
fun toDoubleArray(): DoubleArray

Casts to DoubleArray.

toInt
Link copied to clipboard
fun toInt(): IntVector2

Casts to IntVector2.

unaryMinus
Link copied to clipboard
operator fun unaryMinus(): Vector2
vector3
Link copied to clipboard
fun vector3(x: Double = this.x, y: Double = this.y, z: Double = 0.0): Vector3

Upcasts to Vector3.

vector4
Link copied to clipboard
fun vector4(x: Double = this.x, y: Double = this.y, z: Double = 0.0, w: Double = 0.0): Vector4

Upcasts to Vector4.

Properties

length
Link copied to clipboard
val length: Double

The Euclidean length of the vector.

normalized
Link copied to clipboard
val normalized: Vector2

Returns a normalized version of the vector. (i.e. unit vector)

squaredLength
Link copied to clipboard
val squaredLength: Double

The squared Euclidean length of the vector.

x
Link copied to clipboard
val x: Double
xx
Link copied to clipboard
val xx: Vector2
xy0
Link copied to clipboard
val xy0: Vector3
xy00
Link copied to clipboard
val xy00: Vector4
xy01
Link copied to clipboard
val xy01: Vector4
xy1
Link copied to clipboard
val xy1: Vector3
y
Link copied to clipboard
val y: Double
yx
Link copied to clipboard
val yx: Vector2
yy
Link copied to clipboard
val yy: Vector2

Extensions

clamp
Link copied to clipboard
fun Vector2.clamp(min: Vector2, max: Vector2): Vector2

Returns Vector2 whose value is limited between min and max per vector component.

map
Link copied to clipboard
fun Vector2.map(beforeLeft: Vector2, beforeRight: Vector2, afterLeft: Vector2, afterRight: Vector2, clamp: Boolean = false): Vector2
mod
Link copied to clipboard
fun Vector2.mod(b: Vector2): Vector2
saturate
Link copied to clipboard
fun Vector2.saturate(): Vector2
smoothstep
Link copied to clipboard
fun Vector2.smoothstep(edge0: Vector2, edge1: Vector2): Vector2