Package org.openrndr.math

Types

Link copied to clipboard
interface CastableToVector4
Link copied to clipboard
class CatmullRom1 @JvmOverloads constructor(    val p0: Double,     val p1: Double,     val p2: Double,     val p3: Double,     val alpha: Double = 0.5)

Creates a 1D Catmull-Rom spline curve.

Link copied to clipboard
class CatmullRom2 @JvmOverloads constructor(    val p0: Vector2,     val p1: Vector2,     val p2: Vector2,     val p3: Vector2,     val alpha: Double = 0.5)

Creates a 2D Catmull-Rom spline curve.

Link copied to clipboard
class CatmullRom3 @JvmOverloads constructor(    val p0: Vector3,     val p1: Vector3,     val p2: Vector3,     val p3: Vector3,     val alpha: Double = 0.5)

Creates a 3D Catmull-Rom spline curve.

Link copied to clipboard
class CatmullRomChain1 @JvmOverloads constructor(    points: List<Double>,     alpha: Double = 0.5,     val loop: Boolean = false)

Calculates the 1D Catmull–Rom spline for a chain of points and returns the combined curve.

Link copied to clipboard
class CatmullRomChain2 @JvmOverloads constructor(    points: List<Vector2>,     alpha: Double = 0.5,     val loop: Boolean = false)

Calculates the 2D Catmull–Rom spline for a chain of points and returns the combined curve.

Link copied to clipboard
class CatmullRomChain3 @JvmOverloads constructor(    points: List<Vector3>,     alpha: Double = 0.5,     val loop: Boolean = false)

Calculates the 3D Catmull–Rom spline for a chain of points and returns the combined curve.

Link copied to clipboard
interface EuclideanVector<T : EuclideanVector<T>, LinearType<T>> : LinearType<T>
Link copied to clipboard
object Hashes

From ztellman's Artifex library

Link copied to clipboard
data class IntVector2(val x: Int, val y: Int)

Integer 2D vector, exclusively for integer calculations.

Link copied to clipboard
data class IntVector3(    val x: Int,     val y: Int,     val z: Int)

Integer 3D vector, exclusively for integer calculations.

Link copied to clipboard
data class IntVector4(    val x: Int,     val y: Int,     val z: Int,     val w: Int)

Integer 4D vector, exclusively for integer calculations.

Link copied to clipboard
class LinearRange<T : LinearType<T>>(val start: T, val end: T)
Link copied to clipboard
interface LinearType<T : LinearType<T>>
Link copied to clipboard
data class Matrix33(    val c0r0: Double = 0.0,     val c1r0: Double = 0.0,     val c2r0: Double = 0.0,     val c0r1: Double = 0.0,     val c1r1: Double = 0.0,     val c2r1: Double = 0.0,     val c0r2: Double = 0.0,     val c1r2: Double = 0.0,     val c2r2: Double = 0.0) : LinearType<Matrix33>

A 3x3 matrix with double precision

Link copied to clipboard
data class Matrix44(    val c0r0: Double = 0.0,     val c1r0: Double = 0.0,     val c2r0: Double = 0.0,     val c3r0: Double = 0.0,     val c0r1: Double = 0.0,     val c1r1: Double = 0.0,     val c2r1: Double = 0.0,     val c3r1: Double = 0.0,     val c0r2: Double = 0.0,     val c1r2: Double = 0.0,     val c2r2: Double = 0.0,     val c3r2: Double = 0.0,     val c0r3: Double = 0.0,     val c1r3: Double = 0.0,     val c2r3: Double = 0.0,     val c3r3: Double = 0.0) : LinearType<Matrix44>

A 4x4 matrix with double precision

Link copied to clipboard
data class Matrix55(    val c0r0: Double = 0.0,     val c1r0: Double = 0.0,     val c2r0: Double = 0.0,     val c3r0: Double = 0.0,     val c4r0: Double = 0.0,     val c0r1: Double = 0.0,     val c1r1: Double = 0.0,     val c2r1: Double = 0.0,     val c3r1: Double = 0.0,     val c4r1: Double = 0.0,     val c0r2: Double = 0.0,     val c1r2: Double = 0.0,     val c2r2: Double = 0.0,     val c3r2: Double = 0.0,     val c4r2: Double = 0.0,     val c0r3: Double = 0.0,     val c1r3: Double = 0.0,     val c2r3: Double = 0.0,     val c3r3: Double = 0.0,     val c4r3: Double = 0.0,     val c0r4: Double = 0.0,     val c1r4: Double = 0.0,     val c2r4: Double = 0.0,     val c3r4: Double = 0.0,     val c4r4: Double = 0.0)

A 5x5 matrix with double precision

Link copied to clipboard
data class Polar(val theta: Double, val radius: Double = 1.0) : LinearType<Polar>

A 2D point defined in the Polar coordinate system.

Link copied to clipboard
data class Quaternion(    val x: Double,     val y: Double,     val z: Double,     val w: Double)

Quaternion class for representing orientations in 3D space

Link copied to clipboard
data class Spherical(    val theta: Double,     val phi: Double,     val radius: Double) : LinearType<Spherical>
Link copied to clipboard
value class Vector1(val x: Double) : EuclideanVector<Vector1>
Link copied to clipboard
data class Vector2(val x: Double, val y: Double) : LinearType<Vector2> , EuclideanVector<Vector2>

Double-precision 2D vector.

Link copied to clipboard
data class Vector3(    val x: Double,     val y: Double,     val z: Double) : LinearType<Vector3> , EuclideanVector<Vector3>

Double-precision 3D vector.

Link copied to clipboard
data class Vector4(    val x: Double,     val y: Double,     val z: Double,     val w: Double) : LinearType<Vector4> , EuclideanVector<Vector4>

Double-precision 4D vector.

Link copied to clipboard
enum YPolarity : Enum<YPolarity>

Functions

Link copied to clipboard
fun Iterable<Vector2>.average(): Vector2
fun Iterable<Vector3>.average(): Vector3
fun Iterable<Vector4>.average(): Vector4
Link copied to clipboard
fun <T : LinearType<T>> bezier(    x0: T,     c0: T,     x1: T,     t: Double): T
fun bezier(    x0: Double,     c0: Double,     x1: Double,     t: Double): Double
fun bezier(    x0: Vector2,     c0: Vector2,     x1: Vector2,     t: Double): Vector2
fun bezier(    x0: Vector3,     c0: Vector3,     x1: Vector3,     t: Double): Vector3
fun <T : LinearType<T>> bezier(    x0: T,     c0: T,     c1: T,     x1: T,     t: Double): T
fun bezier(    x0: Double,     c0: Double,     c1: Double,     x1: Double,     t: Double): Double
fun bezier(    x0: Vector2,     c0: Vector2,     c1: Vector2,     x1: Vector2,     t: Double): Vector2

fun bezier(    x0: Vector3,     c0: Vector3,     c1: Vector3,     x1: Vector3,     t: Double): Vector3

Samples a single point based on the provided t value from given 3D cubic Bézier curve.

Link copied to clipboard
fun List<Vector2>.catmullRom(alpha: Double = 0.5, closed: Boolean): CatmullRomChain2
fun List<Vector3>.catmullRom(alpha: Double = 0.5, closed: Boolean): CatmullRomChain3
Link copied to clipboard
tailrec fun chaikinSmooth(    polyline: List<Vector2>,     iterations: Int = 1,     closed: Boolean = false,     bias: Double = 0.25): List<Vector2>

Chaikin's corner cutting algorithm generates an approximating curve from a polyline

Link copied to clipboard
@JvmName(name = "doubleClamp")
fun Double.clamp(min: Double, max: Double): Double
@JvmName(name = "intClamp")
fun Int.clamp(min: Int, max: Int): Int

fun IntVector2.clamp(min: IntVector2, max: IntVector2): IntVector2

Returns IntVector2 whose value is limited between min and max per vector component.

fun IntVector3.clamp(min: IntVector3, max: IntVector3): IntVector3

Returns IntVector3 whose value is limited between min and max per vector component.

fun IntVector4.clamp(min: IntVector4, max: IntVector4): IntVector4

Returns IntVector4 whose value is limited between min and max per vector component.

fun Vector2.clamp(min: Vector2, max: Vector2): Vector2

Returns Vector2 whose value is limited between min and max per vector component.

fun Vector3.clamp(min: Vector3, max: Vector3): Vector3

Returns Vector3 whose value is limited between min and max per vector component.

fun Vector4.clamp(min: Vector4, max: Vector4): Vector4

Returns Vector4 whose value is limited between min and max per vector component.

fun clamp(    value: Double,     min: Double,     max: Double): Double
fun clamp(    value: Int,     min: Int,     max: Int): Int

Returns number whose value is limited between min and max.

Link copied to clipboard
fun derivative(    x0: Double,     c0: Double,     x1: Double,     t: Double): Double
fun derivative(    x0: Vector2,     c0: Vector2,     x1: Vector2,     t: Double): Vector2
fun derivative(    x0: Vector3,     c0: Vector3,     x1: Vector3,     t: Double): Vector3
fun derivative(    p0: Vector2,     p1: Vector2,     p2: Vector2,     p3: Vector2,     t: Double): Vector2
fun derivative(    p0: Vector3,     p1: Vector3,     p2: Vector3,     p3: Vector3,     t: Double): Vector3
Link copied to clipboard
fun dot(q1: Quaternion, q2: Quaternion): Double
Link copied to clipboard
fun linearstep(    edge0: Double,     edge1: Double,     x: Double): Double
Link copied to clipboard
fun Double.map(    before: ClosedFloatingPointRange<Double>,     after: ClosedFloatingPointRange<Double>,     clamp: Boolean = false): Double
fun map(    before: ClosedFloatingPointRange<Double>,     after: ClosedFloatingPointRange<Double>,     value: Double,     clamp: Boolean = false): Double
fun map(    beforeLeft: Double,     beforeRight: Double,     afterLeft: Double,     afterRight: Double,     value: Double,     clamp: Boolean = false): Double

Linearly maps a value, which is given in the before domain to a value in the after domain.

@JvmName(name = "doubleMap")
fun Double.map(    beforeLeft: Double,     beforeRight: Double,     afterLeft: Double,     afterRight: Double,     clamp: Boolean = false): Double

Linearly maps a value, which is given in the before domain to a value in the after domain

fun Vector2.map(    beforeLeft: Vector2,     beforeRight: Vector2,     afterLeft: Vector2,     afterRight: Vector2,     clamp: Boolean = false): Vector2
fun Vector3.map(    beforeLeft: Vector3,     beforeRight: Vector3,     afterLeft: Vector3,     afterRight: Vector3,     clamp: Boolean = false): Vector3
fun Vector4.map(    beforeLeft: Vector4,     beforeRight: Vector4,     afterLeft: Vector4,     afterRight: Vector4,     clamp: Boolean = false): Vector4
Link copied to clipboard
fun max(a: Vector2, b: Vector2): Vector2
fun max(a: Vector3, b: Vector3): Vector3
fun max(a: Vector4, b: Vector4): Vector4
Link copied to clipboard
fun min(a: Vector2, b: Vector2): Vector2
fun min(a: Vector3, b: Vector3): Vector3
fun min(a: Vector4, b: Vector4): Vector4
Link copied to clipboard
fun mix(    left: Double,     right: Double,     x: Double): Double
fun mix(    a: Vector2,     b: Vector2,     mix: Double): Vector2
fun mix(    a: Vector3,     b: Vector3,     mix: Double): Vector3
fun mix(    a: Vector4,     b: Vector4,     mix: Double): Vector4
Link copied to clipboard
fun mixAngle(    leftAngle: Double,     rightAngle: Double,     x: Double): Double

Similar to mix() but assuming that 355° and 5° are 10° apart, not 350°.

Link copied to clipboard
fun IntVector2.mod(b: IntVector2): IntVector2
fun IntVector3.mod(b: IntVector3): IntVector3
fun IntVector4.mod(b: IntVector4): IntVector4
fun Vector2.mod(b: Vector2): Vector2
fun Vector3.mod(b: Vector3): Vector3
fun Vector4.mod(b: Vector4): Vector4
fun mod(a: Double, b: Double): Double
fun mod(a: Float, b: Float): Float
fun mod(a: Int, b: Int): Int
fun mod(a: Long, b: Long): Long
Link copied to clipboard
fun normal(    x0: Vector2,     c0: Vector2,     x1: Vector2,     t: Double): Vector2
Link copied to clipboard
fun normalizationFactor(a: Double, b: Double): Double
fun normalizationFactor(    a: Double,     b: Double,     c: Double): Double
fun normalizationFactor(    a: Double,     b: Double,     c: Double,     d: Double): Double
Link copied to clipboard
fun roots(p: List<Double>): List<Double>
Link copied to clipboard
fun safeDerivative(    p0: Vector2,     c0: Vector2,     p1: Vector2,     t: Double): Vector2

Similar to derivative but handles cases in which p0 and p1 coincide.

fun safeDerivative(    p0: Vector2,     p1: Vector2,     p2: Vector2,     p3: Vector2,     t: Double): Vector2

Similar to derivative but handles cases in which p0 and p1 or p2 and p3 coincide.

Link copied to clipboard
@JvmName(name = "doubleSaturate")
fun Double.saturate(): Double
fun Vector2.saturate(): Vector2
fun Vector3.saturate(): Vector3
fun Vector4.saturate(): Vector4
fun saturate(x: Double): Double
Link copied to clipboard
fun slerp(    q1: Quaternion,     q2: Quaternion,     x: Double): Quaternion
Link copied to clipboard
fun smootherstep(    edge0: Double,     edge1: Double,     x: Double): Double

Smootherstep

Link copied to clipboard
@JvmName(name = "doubleSmoothstep")
fun Double.smoothstep(edge0: Double, edge1: Double): Double
fun Vector2.smoothstep(edge0: Vector2, edge1: Vector2): Vector2
fun Vector3.smoothstep(edge0: Vector3, edge1: Vector3): Vector3
fun Vector4.smoothstep(edge0: Vector4, edge1: Vector4): Vector4

fun smoothstep(    edge0: Double,     edge1: Double,     x: Double): Double

Smoothstep

Link copied to clipboard
fun smoothstepIn(    edge0: Double,     edge1: Double,     x: Double): Double

Smoothstep

Link copied to clipboard
fun solveCubic(    a: Double,     b: Double,     c: Double,     d: Double): DoubleArray
fun solveCubic(    a: Double,     b: Double,     c: Double,     d: Double,     acc: DoubleArray): Int
Link copied to clipboard
fun solveLinear(a: Double, b: Double): DoubleArray
fun solveLinear(    a: Double,     b: Double,     acc: DoubleArray): Int
Link copied to clipboard
fun solveQuadratic(    a: Double,     b: Double,     c: Double): DoubleArray
fun solveQuadratic(    a: Double,     b: Double,     c: Double,     acc: DoubleArray): Int
Link copied to clipboard
fun Iterable<Vector2>.sum(): Vector2
fun Iterable<Vector3>.sum(): Vector3
fun Iterable<Vector4>.sum(): Vector4
Link copied to clipboard
operator fun Double.times(m: Matrix33): Matrix33
operator fun Double.times(m: Matrix44): Matrix44
operator fun Double.times(v: Vector2): Vector2
operator fun Double.times(v: Vector3): Vector3
operator fun Double.times(v: Vector4): Vector4
operator fun Int.times(v: IntVector2): IntVector2
operator fun Int.times(v: IntVector3): IntVector3
operator fun Int.times(v: IntVector4): IntVector4

Properties

Link copied to clipboard
val Double.asDegrees: Double
Link copied to clipboard
val Double.asExponent: Int
Link copied to clipboard
val Double.asRadians: Double