Vec2

data class Vec2(val x: Double, val y: Double) : Spatial, Distanceable<Vec2> , Vector<Vec2> (source)

This class represents two-dimensional vectors and points in a Euclidean space.

Constructors

Link copied to clipboard
constructor(vector: Vec2)

Creates a new vector by copying the coordinates from another vector.

constructor(x: Double, y: Double)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val x: Double

The x-coordinate of the vector.

Link copied to clipboard
val y: Double

The y-coordinate of the vector.

Functions

Link copied to clipboard
open override fun angle(other: Vec2, angleUnit: AngleUnit): Double

Calculate the angle between this vector and another vector.

Link copied to clipboard
open override fun dimensions(): Int

Returns the number of dimensions of the spatial object.

Link copied to clipboard
open infix override fun distance(other: Vec2): Double

Compute the distance to another point.

Link copied to clipboard
open infix override fun dot(other: Vec2): Double

Calculate the dot product of this vector with another vector.

Link copied to clipboard
fun eq(other: Vec2, equivalence: DoubleEquivalence = DEFAULT_DOUBLE_EQUIVALENCE): Boolean

Tests if two vectors are approximately equal.

Link copied to clipboard
open override fun isFinite(): Boolean

Returns true if all values in the spatial are finite.

Link copied to clipboard
open override fun isInfinite(): Boolean

Returns true if any value in the spatial is infinite.

Link copied to clipboard
open override fun isNaN(): Boolean

Returns true if any value in the spatial is NaN (Not a Number).

Link copied to clipboard
fun lerp(other: Vec2, t: Double): Vec2

Performs linear interpolation between this vector and another vector.

Link copied to clipboard
open operator override fun minus(other: Vec2): Vec2

Subtracts another vector from this vector.

Link copied to clipboard
open override fun norm(): Double

Calculates the norm (magnitude) of the vector.

Link copied to clipboard
open override fun normalize(): Vec2

Normalizes the vector.

Link copied to clipboard
open operator override fun plus(other: Vec2): Vec2

Add a vector to this vector.

Link copied to clipboard
fun project(base: Vec2): Vec2

Calculate the projection of this vector onto another vector.

Link copied to clipboard
fun reject(base: Vec2): Vec2

Calculates the rejection of this vector from another vector.

Link copied to clipboard
fun signedArea(other: Vec2): Double

Computes the signed area of the parallelogram formed by this vector and another vector.

Link copied to clipboard
open operator override fun times(scalar: Double): Vec2

Scale this vector by a scalar value.

Link copied to clipboard
open operator override fun unaryMinus(): Vec2

Negates the vector, flipping its direction.

Link copied to clipboard
open override fun zero(): Vec2

Get Zero vector.