Package-level declarations

Core data types.

Core data types.

Core data types.

Types

Link copied to clipboard

Combined angle measure in degrees and radians.

Link copied to clipboard
data class AngleRange<T : Number, Comparable<T>>(val start: Angle<T>, val endInclusive: Angle<T>) : ClosedRange<Angle<T>>

A range of values of type Angle.

Link copied to clipboard
abstract class BaseMat<T : Number, Comparable<T>, M : Mat<T, M, V>, V : Vec<T>>(dimension: Int) : Mat<T, M, V>

Base implementation of a square matrix with a given dimension.

Link copied to clipboard
interface Mat<T : Number, Comparable<T>, M : Mat<T, M, V>, V : Vec<T>>

A common interface for square matrix implementations.

Link copied to clipboard
data class Mat2<T : Number, Comparable<T>>(elements: List<T>, val type: KClass<T>) : BaseMat<T, Mat2<T>, Vec2<T>>

A 2×2 matrix.

Link copied to clipboard
data class Mat3<T : Number, Comparable<T>>(elements: List<T>, val type: KClass<T>) : BaseMat<T, Mat3<T>, Vec3<T>>

A 3×3 matrix.

Link copied to clipboard
data class Mat4<T : Number, Comparable<T>>(elements: List<T>, val type: KClass<T>) : BaseMat<T, Mat4<T>, Vec4<T>>

A 4×4 matrix.

Link copied to clipboard
interface Vec<T : Number, Comparable<T>>

A common interface for vector implementations.

Link copied to clipboard
data class Vec2<T : Number, Comparable<T>>(val x: T, val y: T, val type: KClass<T>) : Vec<T>

2D vector with coordinates (x, y).

Link copied to clipboard
data class Vec3<T : Number, Comparable<T>>(val x: T, val y: T, val z: T, val type: KClass<T>) : Vec<T>

3D vector with coordinates (x, y, z).

Link copied to clipboard
data class Vec4<T : Number, Comparable<T>>(val x: T, val y: T, val z: T, val w: T, val type: KClass<T>) : Vec<T>

4D vector with coordinates (x, y, z, w).

Functions

Link copied to clipboard
fun <T : Number> atan(x: T): T

Returns tangent of number x.

Link copied to clipboard
fun <T : Number> atan2(y: T, x: T): T

Returns tangent of number (y/x).

Link copied to clipboard
fun <T : Number, Comparable<T>> cos(angle: Angle<T>): T

Computes the cosine of the given angle.

Link copied to clipboard
operator fun <T : Number> T.div(other: Number): T

Returns quotient of this number and the other number.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> frustum(left: T, right: T, bottom: T, top: T, near: T, far: T): Mat4<T>
fun <T : Number, Comparable<T>> frustum(left: T, right: T, bottom: T, top: T, near: T, far: T, type: KClass<T>): Mat4<T>

Creates a projection matrix for a perspective projection defined by a given frustum.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> lookAt(eye: Vec3<T>, target: Vec3<T>, upVector: Vec3<T>): Mat4<T>
fun <T : Number, Comparable<T>> lookAt(eye: Vec3<T>, target: Vec3<T>, upVector: Vec3<T>, type: KClass<T>): Mat4<T>

Creates a view matrix defined by an eye position, a target point, and an upVector.

Link copied to clipboard
fun <T : Number, Comparable<T>> magnitude(vector: Vec2<T>): T
fun <T : Number, Comparable<T>> magnitude(vector: Vec3<T>): T

Returns the magnitude of the given vector.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> Mat2(elements: List<T>): Mat2<T>

Returns a new 2×2 matrix from given elements.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> Mat3(elements: List<T>): Mat3<T>

Returns a new 3×3 matrix from given elements.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> Mat4(elements: List<T>): Mat4<T>

Returns a new 4×4 matrix from given elements.

Link copied to clipboard
fun <T : Number, Comparable<T>> max(a: T, b: T): T

Returns larger of the given values a and b.

Link copied to clipboard
fun <T : Number, Comparable<T>> min(a: T, b: T): T

Returns lesser of the given values a and b.

Link copied to clipboard
operator fun <T : Number> T.minus(other: Number): T

Returns difference of this number and the other number.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> mirror(normal: Vec3<T>, origin: Vec3<T>): Mat4<T>
fun <T : Number, Comparable<T>> mirror(normal: Vec3<T>, origin: Vec3<T>, type: KClass<T>): Mat4<T>

Creates a transformation matrix for mirroring through a plane passing through the origin point, and perpendicular a given normal vector.

Link copied to clipboard
fun <T : Number, Comparable<T>> normalize(vector: Vec2<T>): Vec2<T>
fun <T : Number, Comparable<T>> normalize(vector: Vec3<T>): Vec3<T>

Returns a unit vector in the direction of the given vector.

Link copied to clipboard
inline fun <T : Number> one(): T

Returns value of one for type T.

fun <T : Number> one(type: KClass<T>): T

Returns value of one for given type.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> orthographic(left: T, right: T, bottom: T, top: T, near: T, far: T): Mat4<T>
fun <T : Number, Comparable<T>> orthographic(left: T, right: T, bottom: T, top: T, near: T, far: T, type: KClass<T>): Mat4<T>

Creates a projection matrix for an orthographic (parallel) projection defined by a given set of clipping planes: left, right, bottom, top, near and far.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> perspective(fovY: Angle<T>, aspect: T, near: T, far: T): Mat4<T>
fun <T : Number, Comparable<T>> perspective(fovY: Angle<T>, aspect: T, near: T, far: T, type: KClass<T>): Mat4<T>

Creates a projection matrix for a perspective projection defined by a given frustum.

Link copied to clipboard
operator fun <T : Number> T.plus(other: Number): T

Returns sum of this number and the other number.

Link copied to clipboard
operator fun <T : Number> T.rem(other: Number): T

Returns remainder of dividing this number by the other number.

Link copied to clipboard
fun <T : Number, Comparable<T>> rotation(axis: Vec3<T>, angle: Angle<T>): Mat4<T>

Creates a transformation matrix for a rotation by a given angle around a given axis.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> rotationX(angle: Angle<T>): Mat4<T>
fun <T : Number, Comparable<T>> rotationX(angle: Angle<T>, type: KClass<T>): Mat4<T>

Creates a transformation matrix for a rotation by a given angle around X axis.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> rotationY(angle: Angle<T>): Mat4<T>
fun <T : Number, Comparable<T>> rotationY(angle: Angle<T>, type: KClass<T>): Mat4<T>

Creates a transformation matrix for a rotation by a given angle around Y axis.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> rotationZ(angle: Angle<T>): Mat4<T>
fun <T : Number, Comparable<T>> rotationZ(angle: Angle<T>, type: KClass<T>): Mat4<T>

Creates a transformation matrix for a rotation by a given angle around Z axis.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> scale(scale: T): Mat4<T>
fun <T : Number, Comparable<T>> scale(scale: T, type: KClass<T>): Mat4<T>

Creates a transformation matrix for scaling by a given scale.

inline fun <T : Number, Comparable<T>> scale(x: T = one(), y: T = one(), z: T = one()): Mat4<T>
fun <T : Number, Comparable<T>> scale(x: T, y: T, z: T, type: KClass<T>): Mat4<T>

Creates a transformation matrix for scaling by a given scale in x, y and z directions.

Link copied to clipboard
fun <T : Number, Comparable<T>> sin(angle: Angle<T>): T

Computes the sine of the given angle.

Link copied to clipboard
fun <T : Number> sqrt(x: T): T

Returns square root of number x.

Link copied to clipboard
inline fun <T : Number> List<T>.sum(): T
fun <T : Number> List<T>.sum(type: KClass<T>): T

Returns sum of the numbers in this list.

Link copied to clipboard
fun <T : Number, Comparable<T>> tan(angle: Angle<T>): T

Computes the tangent of the given angle.

Link copied to clipboard
operator fun <T : Number> T.times(other: Number): T

Returns product of this number and the other number.

Link copied to clipboard

Returns a Compose Color representation of this Vec3.

Returns a Compose Color representation of this Vec4.

Link copied to clipboard

Returns a color int representation of this Vec3.

Returns a color int representation of this Vec4.

Link copied to clipboard

Returns an array of elements of this matrix.

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns an array of elements of this matrix.

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns an array of coordinates of this vector.

Link copied to clipboard

Returns a Vec3 representation of this color int.

Returns a Vec3 representation of this Color.

Link copied to clipboard

Returns a Vec4 representation of this color int.

Returns a Vec4 representation of this Color.

Link copied to clipboard
fun <T : Number, Comparable<T>> translation(vector: Vec3<T>): Mat4<T>

Creates a transformation matrix for a translation by a given vector.

Link copied to clipboard
operator fun <T : Number> T.unaryMinus(): T

Returns a number opposite to this number.

Link copied to clipboard
operator fun <T : Number> T.unaryPlus(): T

Returns this number.

Link copied to clipboard
inline fun <T : Number, Comparable<T>> Vec2(x: T, y: T): Vec2<T>

Returns a new 2D vector with coordinates (x, y).

Link copied to clipboard
fun Vec3(@ColorInt color: Int): Vec3<Float>

Returns a Vec3 representation of a given color.

inline fun <T : Number, Comparable<T>> Vec3(x: T, y: T, z: T): Vec3<T>

Returns a new 3D vector with coordinates (x, y, z).

fun Vec3(color: Color): Vec3<Float>

Returns a Vec3 representation of a given color.

Link copied to clipboard
fun Vec4(@ColorInt color: Int): Vec4<Float>

Returns a Vec4 representation of a given color.

inline fun <T : Number, Comparable<T>> Vec4(x: T, y: T, z: T, w: T): Vec4<T>

Returns a new 4D vector with coordinates (x, y, z, w).

fun Vec4(color: Color): Vec4<Float>

Returns a Vec4 representation of a given color.

Link copied to clipboard
inline fun <T : Number> zero(): T

Returns value of zero for type T.

fun <T : Number> zero(type: KClass<T>): T

Returns value of zero for given type.