ImmutableVector

Represent an immutable vector.

This is the root interface of immutable alternatives to the default mutable vectors provided by libGDX.

Inheritors

Properties

Link copied to clipboard
open val len: Float

Returns the euclidean length

Link copied to clipboard
abstract val len2: Float

Returns the squared euclidean length

Link copied to clipboard
abstract val nor: T

Returns the unit vector of same direction or this vector if it is zero.

Functions

Link copied to clipboard
open fun add(v: T): T
Link copied to clipboard
open fun clamp(min: Float, max: Float): T
Link copied to clipboard
open operator override fun compareTo(other: T): Int
Link copied to clipboard
abstract operator fun dec(): T

Returns a new vector instance with all members decremented by 1

Link copied to clipboard
abstract infix fun dot(vector: T): Float

Returns the dot product of this vector by the given vector

Link copied to clipboard
abstract infix fun dst2(vector: T): Float

Returns the squared distance between this and the other vector

Link copied to clipboard
abstract fun epsilonEquals(other: T, epsilon: Float): Boolean

Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing

Link copied to clipboard
abstract operator fun inc(): T

Returns a new vector instance with all members incremented by 1

Link copied to clipboard
open fun interpolate(target: T, alpha: Float, interpolator: Interpolation): T
Link copied to clipboard
abstract fun isOnLine(other: T, epsilon: Float = MathUtils.FLOAT_ROUNDING_ERROR): Boolean

Returns true if this vector is on-line with the other vector (either in the same or the opposite direction)

Link copied to clipboard
open fun isUnit(margin: Float = MathUtils.FLOAT_ROUNDING_ERROR): Boolean

Returns whether this vector is a unit length vector within the given margin. (no margin by default)

Link copied to clipboard
abstract fun isZero(margin: Float = MathUtils.FLOAT_ROUNDING_ERROR): Boolean

Returns whether the length of this vector is smaller than the given margin

Link copied to clipboard
open fun lerp(target: T, alpha: Float): T
Link copied to clipboard
open fun limit(limit: Float): T
Link copied to clipboard
open fun limit2(limit2: Float): T
Link copied to clipboard
abstract operator fun minus(other: T): T

Returns the result of subtracting the other vector from this vector

Link copied to clipboard
open fun mulAdd(v: T, mulVec: T): T
open fun mulAdd(v: T, scalar: Float): T
Link copied to clipboard
open fun nor(): T
Link copied to clipboard
abstract operator fun plus(other: T): T

Returns the result of adding the other vector to this vector

Link copied to clipboard
open fun scl(v: T): T
open fun scl(scalar: Float): T
Link copied to clipboard
open fun set(v: T): T
Link copied to clipboard
open fun setLength(len: Float): T
Link copied to clipboard
open fun setLength2(len2: Float): T
Link copied to clipboard
Link copied to clipboard
open fun sub(v: T): T
Link copied to clipboard
abstract operator fun times(vector: T): T

Returns a new vector instance scaled by the given vector

abstract operator fun times(scalar: Float): T

Returns a new vector instance scaled by the given scalar

Link copied to clipboard
abstract operator fun unaryMinus(): T

Returns the opposite vector of same length

Link copied to clipboard
open fun withClamp(min: Float, max: Float): T

Returns a vector of same direction and the length clamped between min and max

Link copied to clipboard
abstract fun withClamp2(min2: Float, max2: Float): T

Returns a vector of same direction and the squared length clamped between min2 and max2

Link copied to clipboard
open fun withInterpolation(target: T, alpha: Float, interpolation: Interpolation): T

Returns the result of interpolation between this vector and the given target vector by alpha (within range 0,1) using the given interpolation method.

Link copied to clipboard
open fun withLength(length: Float): T

Returns a vector of same direction and the given length

Link copied to clipboard
abstract fun withLength2(length2: Float): T

Returns a vector of the same direction and a squared length of length2

Link copied to clipboard
abstract fun withLerp(target: T, alpha: Float): T

Linearly interpolates between this vector and the target vector by alpha

Link copied to clipboard
open fun withLimit(limit: Float): T

Returns this vector if the ImmutableVector.len is <= limit or a vector with the same direction and length limit otherwise

Link copied to clipboard
abstract fun withLimit2(limit2: Float): T

Returns this vector if the ImmutableVector.len2 is <= limit2 or a vector with the same direction and length limit2 otherwise

Link copied to clipboard
abstract fun withRandomDirection(rng: Random = MathUtils.random): T

Returns a vector of same length and a random direction.