Package org.openrndr.math

Types

CastableToVector4
Link copied to clipboard
interface CastableToVector4
CatmullRom1
Link copied to clipboard
class CatmullRom1(p0: Double, p1: Double, p2: Double, p3: Double, alpha: Double)
Creates a 1D Catmull-Rom spline curve.
CatmullRom2
Link copied to clipboard
class CatmullRom2(p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2, alpha: Double)
Creates a 2D Catmull-Rom spline curve.
CatmullRom3
Link copied to clipboard
class CatmullRom3(p0: Vector3, p1: Vector3, p2: Vector3, p3: Vector3, alpha: Double)
Creates a 3D Catmull-Rom spline curve.
CatmullRomChain1
Link copied to clipboard
class CatmullRomChain1(points: List<Double>, alpha: Double, loop: Boolean)
Calculates the 1D Catmull–Rom spline for a chain of points and returns the combined curve.
CatmullRomChain2
Link copied to clipboard
class CatmullRomChain2(points: List<Vector2>, alpha: Double, loop: Boolean)
Calculates the 2D Catmull–Rom spline for a chain of points and returns the combined curve.
CatmullRomChain3
Link copied to clipboard
class CatmullRomChain3(points: List<Vector3>, alpha: Double, loop: Boolean)
Calculates the 3D Catmull–Rom spline for a chain of points and returns the combined curve.
IntVector2
Link copied to clipboard
data class IntVector2(x: Int, y: Int)
Integer 2D vector, exclusively for integer calculations.
IntVector3
Link copied to clipboard
data class IntVector3(x: Int, y: Int, z: Int)
Integer 3D vector, exclusively for integer calculations.
IntVector4
Link copied to clipboard
data class IntVector4(x: Int, y: Int, z: Int, w: Int)
Integer 4D vector, exclusively for integer calculations.
LinearRange
Link copied to clipboard
class LinearRange<T : LinearType<T>>(start: T, end: T)
LinearType
Link copied to clipboard
interface LinearType<T : LinearType<T>>
Matrix33
Link copied to clipboard
data class Matrix33(c0r0: Double, c1r0: Double, c2r0: Double, c0r1: Double, c1r1: Double, c2r1: Double, c0r2: Double, c1r2: Double, c2r2: Double) : LinearType<Matrix33>
A 3x3 matrix with double precision
Matrix44
Link copied to clipboard
data class Matrix44(c0r0: Double, c1r0: Double, c2r0: Double, c3r0: Double, c0r1: Double, c1r1: Double, c2r1: Double, c3r1: Double, c0r2: Double, c1r2: Double, c2r2: Double, c3r2: Double, c0r3: Double, c1r3: Double, c2r3: Double, c3r3: Double) : LinearType<Matrix44>
A 4x4 matrix with double precision
Matrix55
Link copied to clipboard
data class Matrix55(c0r0: Double, c1r0: Double, c2r0: Double, c3r0: Double, c4r0: Double, c0r1: Double, c1r1: Double, c2r1: Double, c3r1: Double, c4r1: Double, c0r2: Double, c1r2: Double, c2r2: Double, c3r2: Double, c4r2: Double, c0r3: Double, c1r3: Double, c2r3: Double, c3r3: Double, c4r3: Double, c0r4: Double, c1r4: Double, c2r4: Double, c3r4: Double, c4r4: Double)
A 5x5 matrix with double precision
Polar
Link copied to clipboard
data class Polar(theta: Double, radius: Double) : LinearType<Polar>
A 2D point defined in the Polar coordinate system.
Quaternion
Link copied to clipboard
data class Quaternion(x: Double, y: Double, z: Double, w: Double)
Quaternion class for representing orientations in 3D space
Spherical
Link copied to clipboard
data class Spherical(theta: Double, phi: Double, radius: Double) : LinearType<Spherical>
Vector2
Link copied to clipboard
data class Vector2(x: Double, y: Double) : LinearType<Vector2>
Double-precision 2D vector.
Vector3
Link copied to clipboard
data class Vector3(x: Double, y: Double, z: Double) : LinearType<Vector3>
Double-precision 3D vector.
Vector4
Link copied to clipboard
data class Vector4(x: Double, y: Double, z: Double, w: Double) : LinearType<Vector4>
Double-precision 4D vector.
YPolarity
Link copied to clipboard
enum YPolarity : Enum<YPolarity>

Functions

bezier
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.
chaikinSmooth
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 polylineInteractive DemoThe code has been tweaked for performance instead of brevity or being idiomatic.
clamp
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
Returns number whose value is limited between min and max.
fun clamp(value: Int, min: Int, max: Int): Int
Returns number whose value is limited between min and max.
derivative
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
dot
Link copied to clipboard
fun dot(q1: Quaternion, q2: Quaternion): Double
linearstep
Link copied to clipboard
fun linearstep(edge0: Double, edge1: Double, x: Double): Double
map
Link copied to clipboard
fun Double.map(before: ClosedFloatingPointRange<Double>, after: ClosedFloatingPointRange<Double>, clamp: Boolean = false): Double
Linearly maps a value, which is given in the before domain to a value in the after domain.
fun map(before: ClosedFloatingPointRange<Double>, after: ClosedFloatingPointRange<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
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.
max
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
min
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
mix
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
mixAngle
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°.
mod
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
mod_
Link copied to clipboard
@JvmName(name = modDouble)
fun Double.mod_(b: Double): Double
@JvmName(name = modFloat)
fun Float.mod_(b: Float): Float
@JvmName(name = modInt)
fun Int.mod_(b: Int): Int
@JvmName(name = modLong)
fun Long.mod_(b: Long): Long
normal
Link copied to clipboard
fun normal(x0: Vector2, c0: Vector2, x1: Vector2, t: Double): Vector2
normalizationFactor
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
roots
Link copied to clipboard
fun roots(p: List<Double>): List<Double>
safeDerivative
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.
saturate
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
slerp
Link copied to clipboard
fun slerp(q1: Quaternion, q2: Quaternion, x: Double): Quaternion
smootherstep
Link copied to clipboard
fun smootherstep(edge0: Double, edge1: Double, x: Double): Double
Smootherstep
smoothstep
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
smoothstepIn
Link copied to clipboard
fun smoothstepIn(edge0: Double, edge1: Double, x: Double): Double
Smoothstep
solveCubic
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
solveLinear
Link copied to clipboard
fun solveLinear(a: Double, b: Double): DoubleArray
fun solveLinear(a: Double, b: Double, acc: DoubleArray): Int
solveQuadratic
Link copied to clipboard
fun solveQuadratic(a: Double, b: Double, c: Double): DoubleArray
fun solveQuadratic(a: Double, b: Double, c: Double, acc: DoubleArray): Int
times
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

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