You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
900 B
Kotlin

4 years ago
package me.eater.threedom.utils.joml
import org.joml.Matrix4d
4 years ago
import org.joml.Matrix4dc
4 years ago
import org.joml.Vector3d
4 years ago
import org.joml.Vector3dc
4 years ago
4 years ago
fun <T : Number> Matrix4dc.setTranslation(x: T, y: T, z: T): Matrix4d =
Matrix4d(this).setTranslation(x.toDouble(), y.toDouble(), z.toDouble())
4 years ago
4 years ago
val Matrix4dc.translation: Vector3d
get() = getTranslation(Vector3d())
4 years ago
fun Matrix4dc.mutable(): Matrix4d = if (this is Matrix4d) this else Matrix4d(this)
operator fun Matrix4dc.times(rhs: Matrix4dc) = mul(rhs, Matrix4d())
operator fun Matrix4d.times(rhs: Matrix4dc) = mul(rhs)
4 years ago
@Suppress("FunctionName")
4 years ago
fun Vector3d(x: Number, y: Number, z: Number) = Vector3d(x.toDouble(), y.toDouble(), z.toDouble())
operator fun Vector3dc.compareTo(rhs: Vector3dc): Int {
for (i in 0 until 3) {
4 years ago
val c = this[i].compareTo(rhs[i])
if (c != 0) {
return c
}
}
return 0
}