Package-level declarations

Types

Link copied to clipboard

Represent an immutable vector.

Link copied to clipboard

Represent an immutable vector 2D

Functions

Link copied to clipboard

Creates a range defined with the given tolerance above and below this center value.

infix fun Int.amid(tolerance: Int): IntRange

Creates a range defined with the given inclusive tolerance above and below this center value.

Link copied to clipboard
inline fun ImmutableVector2.angleDeg(reference: ImmutableVector2 = ImmutableVector2.X): Float

Returns the angle in degrees of this vector relative to the reference. Angles are towards the positive y-axis (typically counter-clockwise.) between -180 and +180

inline fun ImmutableVector2.angleDeg(referenceX: Float, referenceY: Float): Float

Returns the angle in degrees of this vector relative to the reference vector described by referenceX and referenceY.

Link copied to clipboard
operator fun Vector2.compareTo(vector2: Vector2): Int

Allows to compare which Vector2 has greater overall length.

operator fun Vector3.compareTo(vector3: Vector3): Int

Allows to compare which Vector3 has greater overall length.

operator fun Vector4.compareTo(vector4: Vector4): Int

Allows to compare which Vector4 has greater overall length.

Link copied to clipboard
operator fun Circle.component1(): Float

Operator function that allows to deconstruct this circle.

operator fun Ellipse.component1(): Float

Operator function that allows to deconstruct this ellipse.

operator fun Matrix3.component1(): Float
operator fun Matrix4.component1(): Float

Operator function that allows to deconstruct this matrix.

operator fun Polygon.component1(): Float

Operator function that allows to deconstruct this polygon.

operator fun Polyline.component1(): Float

Operator function that allows to deconstruct this polyline.

operator fun Rectangle.component1(): Float

Operator function that allows to deconstruct this rectangle.

operator fun Vector2.component1(): Float
operator fun Vector3.component1(): Float
operator fun Vector4.component1(): Float

Operator function that allows to deconstruct this vector.

Link copied to clipboard
operator fun Matrix4.component10(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix4.component11(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix4.component12(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix4.component13(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix4.component14(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix4.component15(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix4.component16(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Circle.component2(): Float

Operator function that allows to deconstruct this circle.

operator fun Ellipse.component2(): Float

Operator function that allows to deconstruct this ellipse.

operator fun Matrix3.component2(): Float
operator fun Matrix4.component2(): Float

Operator function that allows to deconstruct this matrix.

operator fun Polygon.component2(): Float

Operator function that allows to deconstruct this polygon.

operator fun Polyline.component2(): Float

Operator function that allows to deconstruct this polyline.

operator fun Rectangle.component2(): Float

Operator function that allows to deconstruct this rectangle.

operator fun Vector2.component2(): Float
operator fun Vector3.component2(): Float
operator fun Vector4.component2(): Float

Operator function that allows to deconstruct this vector.

Link copied to clipboard
operator fun Circle.component3(): Float

Operator function that allows to deconstruct this circle.

operator fun Ellipse.component3(): Float

Operator function that allows to deconstruct this ellipse.

operator fun Matrix3.component3(): Float
operator fun Matrix4.component3(): Float

Operator function that allows to deconstruct this matrix.

operator fun Rectangle.component3(): Float

Operator function that allows to deconstruct this rectangle.

operator fun Vector3.component3(): Float
operator fun Vector4.component3(): Float

Operator function that allows to deconstruct this vector.

Link copied to clipboard
operator fun Ellipse.component4(): Float

Operator function that allows to deconstruct this ellipse.

operator fun Matrix3.component4(): Float
operator fun Matrix4.component4(): Float

Operator function that allows to deconstruct this matrix.

operator fun Rectangle.component4(): Float

Operator function that allows to deconstruct this rectangle.

operator fun Vector4.component4(): Float

Operator function that allows to deconstruct this vector.

Link copied to clipboard
operator fun Matrix3.component5(): Float
operator fun Matrix4.component5(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix3.component6(): Float
operator fun Matrix4.component6(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix3.component7(): Float
operator fun Matrix4.component7(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix3.component8(): Float
operator fun Matrix4.component8(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
operator fun Matrix3.component9(): Float
operator fun Matrix4.component9(): Float

Operator function that allows to deconstruct this matrix.

Link copied to clipboard
infix inline fun ImmutableVector2.crs(other: ImmutableVector2): Float

Calculates the 2D cross product between this and the other vector

Link copied to clipboard
operator fun Vector2.dec(): Vector2

Decrements both vector values - subtracts 1 from x and y. To avoid creating a new vector instance, use Vector2.minusAssign instead.

operator fun Vector3.dec(): Vector3

Decrements all vector values - subtracts 1 from x, y and z. To avoid creating a new vector instance, use Vector3.minusAssign instead.

operator fun Vector4.dec(): Vector4

Decrements all vector values - subtracts 1 from X, Y, Z and W components. To avoid creating a new vector instance, use Vector4.minusAssign instead.

Link copied to clipboard
inline operator fun <T : ImmutableVector<T>> T.div(scalar: Float): T

Returns this vector scaled by (1 / scalar)

operator fun Vector2.div(vector2: Vector2): Vector2
operator fun Vector2.div(scalar: Float): Vector2
operator fun Vector2.div(scalar: Int): Vector2
operator fun Vector3.div(vector3: Vector3): Vector3
operator fun Vector3.div(scalar: Float): Vector3
operator fun Vector3.div(scalar: Int): Vector3
operator fun Vector4.div(vector4: Vector4): Vector4
operator fun Vector4.div(scalar: Float): Vector4
operator fun Vector4.div(scalar: Int): Vector4

Creates a range by scaling this range's start and endInclusive by the denominator.

operator fun IntRange.div(divisor: Int): IntRange

Creates a range by scaling this range's start and endInclusive by the divisor.

Link copied to clipboard
operator fun Vector2.divAssign(vector2: Vector2)
operator fun Vector2.divAssign(scalar: Float)
operator fun Vector2.divAssign(scalar: Int)
operator fun Vector3.divAssign(vector3: Vector3)
operator fun Vector3.divAssign(scalar: Float)
operator fun Vector3.divAssign(scalar: Int)
operator fun Vector4.divAssign(vector4: Vector4)
operator fun Vector4.divAssign(scalar: Float)
operator fun Vector4.divAssign(scalar: Int)
Link copied to clipboard
infix fun Vector2.dot(vector2: Vector2): Float
infix fun Vector3.dot(vector3: Vector3): Float
infix fun Vector4.dot(vector4: Vector4): Float

Custom operator to apply dot multiplication.

Link copied to clipboard
infix inline fun <T : ImmutableVector<T>> T.dst(other: T): Float

Returns the distance between this and the other vector

Link copied to clipboard

Returns whether this vector has opposite direction compared to the other vector.

Link copied to clipboard

Returns whether this vector has similar direction compared to the other vector.

Link copied to clipboard
operator fun Vector2.inc(): Vector2

Increments both vector values - adds 1 to x and y. To avoid creating a new vector instance, use Vector2.plusAssign instead.

operator fun Vector3.inc(): Vector3

Increments all vector values - adds 1 to x, y and z. To avoid creating a new vector instance, use Vector3.plusAssign instead.

operator fun Vector4.inc(): Vector4

Increments all vector values - adds 1 to X, Y, Z and W components. To avoid creating a new vector instance, use Vector4.plusAssign instead.

Link copied to clipboard
fun ClosedRange<Float>.interpolate(progress: Float, interpolation: Interpolation): Float

Interpolate between the start and end of this range.

Link copied to clipboard
fun <T : ImmutableVector<T>> T.isCollinear(other: T, epsilon: Float = MathUtils.FLOAT_ROUNDING_ERROR): Boolean

Returns true if this vector is collinear with the other vector

Link copied to clipboard
fun <T : ImmutableVector<T>> T.isCollinearOpposite(other: T, epsilon: Float = MathUtils.FLOAT_ROUNDING_ERROR): Boolean

Returns true if this vector is opposite collinear with the other vector

Link copied to clipboard
fun <T : ImmutableVector<T>> T.isPerpendicular(other: T, epsilon: Float = MathUtils.FLOAT_ROUNDING_ERROR): Boolean

Returns true if this vector is opposite perpendicular with the other vector

Link copied to clipboard
fun ClosedRange<Float>.lerp(progress: Float): Float

Linearly interpolate between the start and end of this range.

Link copied to clipboard
fun mat3(m00: Float = 0.0f, m01: Float = 0.0f, m02: Float = 0.0f, m10: Float = 0.0f, m11: Float = 0.0f, m12: Float = 0.0f, m20: Float = 0.0f, m21: Float = 0.0f, m22: Float = 0.0f): Matrix3

A utility factory function that allows to create Matrix3 instances with named parameters.

Link copied to clipboard
fun mat4(m00: Float = 0.0f, m01: Float = 0.0f, m02: Float = 0.0f, m03: Float = 0.0f, m10: Float = 0.0f, m11: Float = 0.0f, m12: Float = 0.0f, m13: Float = 0.0f, m20: Float = 0.0f, m21: Float = 0.0f, m22: Float = 0.0f, m23: Float = 0.0f, m30: Float = 0.0f, m31: Float = 0.0f, m32: Float = 0.0f, m33: Float = 0.0f): Matrix4

A utility factory function that allows to create Matrix4 instances with named parameters.

Link copied to clipboard
operator fun Matrix3.minus(matrix3: Matrix3): Matrix3
operator fun Matrix4.minus(matrix4: Matrix4): Matrix4
operator fun Vector2.minus(vector2: Vector2): Vector2
operator fun Vector2.minus(subtrahend: Float): Vector2
operator fun Vector2.minus(subtrahend: Int): Vector2
operator fun Vector3.minus(vector3: Vector3): Vector3
operator fun Vector3.minus(subtrahend: Float): Vector3
operator fun Vector3.minus(subtrahend: Int): Vector3
operator fun Vector4.minus(vector2: Vector2): Vector4
operator fun Vector4.minus(vector3: Vector3): Vector4
operator fun Vector4.minus(vector4: Vector4): Vector4
operator fun Vector4.minus(subtrahend: Float): Vector4
operator fun Vector4.minus(subtrahend: Int): Vector4

operator fun Vector3.minus(vector2: Vector2): Vector3

Modifies x and y components of this vector.

operator fun IntRange.minus(subtrahend: Int): IntRange

Creates a range by shifting this range's start and endInclusive by the subtrahend.

Link copied to clipboard
operator fun Matrix3.minusAssign(matrix3: Matrix3)
operator fun Matrix4.minusAssign(matrix4: Matrix4)
operator fun Vector2.minusAssign(vector2: Vector2)
operator fun Vector2.minusAssign(subtrahend: Float)
operator fun Vector2.minusAssign(subtrahend: Int)
operator fun Vector3.minusAssign(vector3: Vector3)
operator fun Vector3.minusAssign(subtrahend: Float)
operator fun Vector3.minusAssign(subtrahend: Int)
operator fun Vector4.minusAssign(vector4: Vector4)
operator fun Vector4.minusAssign(subtrahend: Float)
operator fun Vector4.minusAssign(subtrahend: Int)

operator fun Vector3.minusAssign(vector2: Vector2)

Modifies x and y components of this vector.

operator fun Vector4.minusAssign(vector2: Vector2)

Modifies X and Y components of this vector.

operator fun Vector4.minusAssign(vector3: Vector3)

Modifies X, Y, and Z components of this vector.

Link copied to clipboard
operator fun Matrix3.not(): Matrix3
operator fun Matrix4.not(): Matrix4

Inverts the current matrix.

Link copied to clipboard
operator fun Matrix3.plus(matrix3: Matrix3): Matrix3
operator fun Matrix4.plus(matrix4: Matrix4): Matrix4
operator fun Vector2.plus(vector2: Vector2): Vector2
operator fun Vector2.plus(addend: Float): Vector2
operator fun Vector2.plus(addend: Int): Vector2
operator fun Vector3.plus(vector3: Vector3): Vector3
operator fun Vector3.plus(addend: Float): Vector3
operator fun Vector3.plus(addend: Int): Vector3
operator fun Vector4.plus(vector2: Vector2): Vector4
operator fun Vector4.plus(vector3: Vector3): Vector4
operator fun Vector4.plus(vector4: Vector4): Vector4
operator fun Vector4.plus(addend: Float): Vector4
operator fun Vector4.plus(addend: Int): Vector4

operator fun Vector3.plus(vector2: Vector2): Vector3

Modifies x and y components of this vector.

operator fun IntRange.plus(addend: Int): IntRange

Creates a range by shifting this range's start and endInclusive by the addend.

Link copied to clipboard
operator fun Matrix3.plusAssign(matrix3: Matrix3)
operator fun Matrix4.plusAssign(matrix4: Matrix4)
operator fun Vector2.plusAssign(vector2: Vector2)
operator fun Vector2.plusAssign(addend: Float)
operator fun Vector2.plusAssign(addend: Int)
operator fun Vector3.plusAssign(vector3: Vector3)
operator fun Vector3.plusAssign(addend: Float)
operator fun Vector3.plusAssign(addend: Int)
operator fun Vector4.plusAssign(vector4: Vector4)
operator fun Vector4.plusAssign(addend: Float)
operator fun Vector4.plusAssign(addend: Int)

operator fun Vector3.plusAssign(vector2: Vector2)

Modifies x and y components of this vector.

operator fun Vector4.plusAssign(vector2: Vector2)

Modifies X and Y components of this vector.

operator fun Vector4.plusAssign(vector3: Vector3)

Modifies X, Y, and Z components of this vector.

Link copied to clipboard

Returns a pseudo-random, uniformly distributed Float value from MathUtils.random's sequence, bounded by this range.

fun IntRange.random(random: Random): Int

Returns a random element from this range using the specified source of randomness.

Link copied to clipboard

Returns a pseudo-random, standard Gaussian distributed Float value from MathUtils.random's sequence. The distribution is centered to this range's center and is scaled so this range is six standard deviations wide.

Link copied to clipboard

Returns a triangularly distributed random number in this range, with the mode centered in this range, giving a symmetric distribution.

Returns a triangularly distributed random number in this range, where values around the mode are more likely. normalizedMode must be a value in the range 0.0..1.0 and represents the fractional position of the mode across the range.

Link copied to clipboard
operator fun Matrix3.times(matrix3: Matrix3): Matrix3
operator fun Matrix3.times(vector2: Vector2): Vector2
operator fun Matrix3.times(scalar: Float): Matrix3
operator fun Matrix4.times(matrix4: Matrix4): Matrix4
operator fun Matrix4.times(vector3: Vector3): Vector3
operator fun Matrix4.times(scalar: Float): Matrix4
operator fun Vector2.times(vector2: Vector2): Vector2
operator fun Vector2.times(scalar: Float): Vector2
operator fun Vector2.times(scalar: Int): Vector2
operator fun Vector3.times(vector3: Vector3): Vector3
operator fun Vector3.times(scalar: Float): Vector3
operator fun Vector3.times(scalar: Int): Vector3
operator fun Vector4.times(vector4: Vector4): Vector4
operator fun Vector4.times(scalar: Float): Vector4
operator fun Vector4.times(scalar: Int): Vector4

operator fun Int.times(range: IntRange): IntRange

Creates a range by scaling the range's start and endInclusive by this multiplier.

operator fun IntRange.times(multiplier: Int): IntRange

Creates a range by scaling this range's start and endInclusive by the multiplier.

Link copied to clipboard
operator fun Matrix3.timesAssign(matrix3: Matrix3)
operator fun Matrix3.timesAssign(scale: Vector2)
operator fun Matrix3.timesAssign(scale: Vector3)
operator fun Matrix3.timesAssign(scalar: Float)
operator fun Matrix4.timesAssign(matrix4: Matrix4)
operator fun Matrix4.timesAssign(scale: Vector2)
operator fun Matrix4.timesAssign(scale: Vector3)
operator fun Matrix4.timesAssign(scalar: Float)
operator fun Vector2.timesAssign(matrix3: Matrix3)
operator fun Vector2.timesAssign(vector2: Vector2)
operator fun Vector2.timesAssign(scalar: Float)
operator fun Vector2.timesAssign(scalar: Int)
operator fun Vector3.timesAssign(matrix4: Matrix4)
operator fun Vector3.timesAssign(vector3: Vector3)
operator fun Vector3.timesAssign(scalar: Float)
operator fun Vector3.timesAssign(scalar: Int)
operator fun Vector4.timesAssign(vector4: Vector4)
operator fun Vector4.timesAssign(scalar: Float)
operator fun Vector4.timesAssign(scalar: Int)
Link copied to clipboard
inline fun Vector2.toImmutable(): ImmutableVector2
Link copied to clipboard
inline fun ImmutableVector2.toMutable(): Vector2
Link copied to clipboard
operator fun Matrix3.unaryMinus(): Matrix3
operator fun Matrix4.unaryMinus(): Matrix4

Inverts currently stored values.

operator fun Vector2.unaryMinus(): Vector2

Inverts currently stored X and Y values.

operator fun Vector3.unaryMinus(): Vector3

Inverts stored X, Y and Z values.

operator fun Vector4.unaryMinus(): Vector4

Inverts stored X, Y, Z, and W values.

Link copied to clipboard
fun vec2(x: Float = 0.0f, y: Float = 0.0f): Vector2

Constructs a new Vector2 instance. An equivalent of Vector2 constructor that supports Kotlin syntax features: named parameters with default values.

Link copied to clipboard
fun vec3(vector2: Vector2, z: Float = 0.0f): Vector3
fun vec3(x: Float = 0.0f, y: Float = 0.0f, z: Float = 0.0f): Vector3

Constructs a new Vector3 instance. An equivalent of Vector3 constructor that supports Kotlin syntax features: named parameters with default values.

Link copied to clipboard
fun vec4(xy: Vector2, zw: Vector2): Vector4

Constructs a new Vector4 instance copying values from the passed Vector2 instances.

fun vec4(xyz: Vector3, w: Float = 0.0f): Vector4

Constructs a new Vector4 instance copying values from the passed Vector3 instance. An equivalent of Vector4 constructor that supports Kotlin syntax features: named parameters with default values.

fun vec4(xy: Vector2, z: Float = 0.0f, w: Float = 0.0f): Vector4
fun vec4(x: Float = 0.0f, y: Float = 0.0f, z: Float = 0.0f, w: Float = 0.0f): Vector4

Constructs a new Vector4 instance. An equivalent of Vector4 constructor that supports Kotlin syntax features: named parameters with default values.

Link copied to clipboard

Returns a vector of same length with the given angle in degree

Link copied to clipboard

Returns a vector of same length rotated by the given angle in degree

Link copied to clipboard
infix fun Vector2.x(vector2: Vector2): Float
infix fun Vector3.x(vector3: Vector3): Vector3

Custom operator to apply cross multiplication.

infix inline fun ImmutableVector2.x(other: ImmutableVector2): Float

Calculates the 2D cross product between this and the other vector