commonMain.ru.casperix.math.Transform.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spine Show documentation
Show all versions of spine Show documentation
Signals for all occasions
package ru.casperix.math
import ru.casperix.math.geometry.fDEGREE_TO_RADIAN
import ru.casperix.math.quad_matrix.float32.Matrix3f
import kotlin.math.cos
import kotlin.math.sin
data class Transform(
val x: Float = 0f,
val y: Float = 0f,
val rotation: Float = 0f,
val scaleX: Float = 0f,
val scaleY: Float = 0f,
val shearX: Float = 0f,
val shearY: Float = 0f,
) {
fun toLHSMatrix():Matrix3f {
return toABCD().toMatrix()
}
private fun toABCD(): TransformABCD {
val radian = rotation * fDEGREE_TO_RADIAN
val cos = cos(radian)
val sin = sin(radian)
return TransformABCD(
x, -y,
cos * scaleX,
-sin* scaleY,
sin * scaleX,
cos* scaleY,
)
// val rx: Float = (rotation + shearX) * fDEGREE_TO_RADIAN
// val ry: Float = (rotation + 90 + shearY) * fDEGREE_TO_RADIAN
// return TransformABCD(
// x, y,
// cos(rx) * scaleX,
// cos(ry) * scaleY,
// sin(rx) * scaleX,
// sin(ry) * scaleY,
// )
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy