Vector

interface Vector<S : Vector<S>>

A generic vector in a multidimensional space.

Parameters

S

self type to prevent vector operations between vectors of different spaces.

Inheritors

Properties

Link copied to clipboard
abstract val coordinates: DoubleArray

Coordinates for a Cartesian space. Implementors must guarantee that internal state is not exposed.

Link copied to clipboard
abstract val dimensions: Int

The dimensions of the space this vector belongs to.

Link copied to clipboard
open val magnitude: Double

Finds the magnitude of a vector.

Link copied to clipboard
open val zero: S

Origin.

Functions

Link copied to clipboard
open fun angleBetween(other: S): Double

Computes the angle in radians between two vectors.

Link copied to clipboard
open fun coerceAtLeast(minimumMagnitude: Double): S
Link copied to clipboard
open fun coerceAtMost(maximumMagnitude: Double): S
Link copied to clipboard
open fun coerceIn(minimumMagnitude: Double, maximumMagnitude: Double): S

Performs a coercion at least and at most.

Link copied to clipboard
abstract fun distanceTo(other: S): Double

Computes the distance between two vectors, interpreted as points in an Euclidean space. Throws IllegalArgumentException if vectors have different dimensions.

Link copied to clipboard
open operator fun div(other: Double): S

Division by a Double.

Link copied to clipboard
open fun dot(other: S): Double

Computes the dot product between two vectors.

Link copied to clipboard
abstract fun fromCoordinates(coordinates: DoubleArray): S

Builds a new Vector from the provided coordinates.

Link copied to clipboard
abstract operator fun get(dim: Int): Double

The coordinate of this vector in the specified dimension relatively to the basis its space is described with.

Link copied to clipboard
abstract operator fun minus(other: S): S

Support for subtraction. Note: the dimensions must coincide.

Link copied to clipboard
abstract fun normal(): S

Find the normal of a vector.

Link copied to clipboard
abstract fun normalized(): S
Link copied to clipboard
abstract operator fun plus(other: S): S

Support for sum. Note: the dimensions must coincide.

Link copied to clipboard
open fun resized(newLen: Double): S
Link copied to clipboard
abstract operator fun times(other: Double): S

Multiplication by a Double.