Vector2

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

Double-precision 2D vector.

Constructors

Link copied to clipboard
constructor(x: Double)
constructor(x: Double, y: Double)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun areaBetween(other: Vector2): Double

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

Link copied to clipboard
open fun atan2(other: Vector2): Double

atan2 style angle between this and other

Link copied to clipboard

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

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

Calculates a cross product between this Vector2 and right.

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

Calculates the Euclidean distance to other.

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

Calculates a dot product between this Vector2 and right.

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

apply function to all components

Link copied to clipboard
fun Vector2.map(beforeLeft: Vector2, beforeRight: Vector2, afterLeft: Vector2, afterRight: Vector2, clamp: Boolean = false): Vector2
Link copied to clipboard
operator fun minus(d: Double): Vector2
open operator override fun minus(right: Vector2): Vector2
Link copied to clipboard
fun mix(o: Vector2, mix: Double): Vector2
Link copied to clipboard
Link copied to clipboard
fun perpendicular(polarity: YPolarity = YPolarity.CW_NEGATIVE_Y): Vector2

Calculates a vector perpendicular to the current one.

Link copied to clipboard
operator fun plus(d: Double): Vector2
open operator override fun plus(right: Vector2): Vector2
Link copied to clipboard
open infix fun projectedOn(on: Vector2): Vector2

project this vector on on

Link copied to clipboard
infix fun reflect(surfaceNormal: Vector2): Vector2
Link copied to clipboard
open infix fun reflectedOver(surfaceNormal: Vector2): Vector2

reflect this vector over surfaceNormal

Link copied to clipboard
fun rotate(degrees: Double, origin: Vector2 = ZERO): Vector2

Creates a new Vector2 with the given rotation and origin.

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

Calculates the squared Euclidean distance to other.

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

Casts to IntVector2.

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

Upcasts to Vector3.

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

Link copied to clipboard
open override val length: Double

The Euclidean length of the vector.

Link copied to clipboard

normalized vector

Link copied to clipboard
open override val squaredLength: Double

The squared Euclidean length of the vector.

Link copied to clipboard
val x: Double
Link copied to clipboard
val xx: Vector2
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val y: Double
Link copied to clipboard
val yx: Vector2
Link copied to clipboard
val yy: Vector2
Link copied to clipboard
open override val zero: Vector2

returns the zero vector