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.
30 lines
894 B
Kotlin
30 lines
894 B
Kotlin
package me.eater.threedom.utils.joml
|
|
|
|
import org.joml.Matrix4d
|
|
import org.joml.Matrix4dc
|
|
import org.joml.Vector3d
|
|
import org.joml.Vector3dc
|
|
|
|
fun <T : Number> Matrix4dc.setTranslation(x: T, y: T, z: T): Matrix4d =
|
|
Matrix4d(this).setTranslation(x.toDouble(), y.toDouble(), z.toDouble())
|
|
|
|
fun Matrix4dc.getTranslation(): Vector3d = getTranslation(Vector3d())
|
|
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)
|
|
|
|
@Suppress("FunctionName")
|
|
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) {
|
|
val c = this[i].compareTo(rhs[i])
|
|
if (c != 0) {
|
|
return c
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|