# Vector2

@Serializable
data class Vector2(val x: Double, val y: Double) : LinearType<Vector2> , EuclideanVector<Vector2>

Double-precision 2D vector.

## Constructors

fun Vector2(x: Double)
fun Vector2(x: Double, y: Double)

object Companion

## Functions

open override fun areaBetween(other: Vector2): Double

returns the area of the parallelogram formed by extruding this over other

open fun atan2(other: Vector2): Double

atan2 style angle between this and other

infix fun cross(right: Vector2): Double

Calculates a cross product between this Vector2 and right.

open override fun distanceTo(other: Vector2): Double

Calculates the Euclidean distance to other.

open operator override fun div(scale: Double): Vector2
operator fun div(d: Vector2): Vector2
open infix override fun dot(right: Vector2): Double

Calculates a dot product between this Vector2 and right.

operator fun get(i: Int): Double
open override fun map(function: (Double) -> Double): Vector2

apply function to all components

operator fun minus(d: Double): Vector2
open operator override fun minus(right: Vector2): Vector2
fun mix(o: Vector2, mix: Double): Vector2
fun perpendicular(polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Vector2

Calculates a vector perpendicular to the current one.

operator fun plus(d: Double): Vector2
open operator override fun plus(right: Vector2): Vector2
open infix fun projectedOn(on: Vector2): Vector2

project this vector on on

infix fun reflect(surfaceNormal: Vector2): Vector2
open infix fun reflectedOver(surfaceNormal: Vector2): Vector2

reflect this vector over surfaceNormal

fun rotate(degrees: Double, origin: Vector2 = ZERO): Vector2

Creates a new Vector2 with the given rotation and origin.

open override fun squaredDistanceTo(other: Vector2): Double

Calculates the squared Euclidean distance to other.

open operator override fun times(scale: Double): Vector2
operator fun times(v: Vector2): Vector2
fun toDoubleArray(): DoubleArray

Casts to DoubleArray.

fun toInt(): IntVector2

Casts to IntVector2.

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

Upcasts to Vector3.

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

Upcasts to Vector4.

## Properties

open override val length: Double

The Euclidean length of the vector.

open val normalized: Vector2

normalized vector

open override val squaredLength: Double

The squared Euclidean length of the vector.

val x: Double
val xx: Vector2
val xy0: Vector3
val xy00: Vector4
val xy01: Vector4
val xy1: Vector3
val y: Double
val yx: Vector2
val yy: Vector2
open override val zero: Vector2

returns the zero vector

## Extensions

fun Vector2.clamp(min: Vector2, max: Vector2): Vector2

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