This repository has been archived by the owner on Jul 8, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,077 additions
and
1,414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
korma/src/commonMain/kotlin/com/soywiz/korma/geom/EulerRotation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.soywiz.korma.geom | ||
|
||
data class EulerRotation( | ||
var x: Angle = 0.degrees, | ||
var y: Angle = 0.degrees, | ||
var z: Angle = 0.degrees | ||
) { | ||
companion object { | ||
fun toQuaternion(roll: Angle, pitch: Angle, yaw: Angle, out: Quaternion = Quaternion()): Quaternion { | ||
val cr = cos(roll * 0.5) | ||
val sr = sin(roll * 0.5) | ||
val cp = cos(pitch * 0.5) | ||
val sp = sin(pitch * 0.5) | ||
val cy = cos(yaw * 0.5) | ||
val sy = sin(yaw * 0.5) | ||
return out.setTo( | ||
(cy * cp * sr - sy * sp * cr), | ||
(sy * cp * sr + cy * sp * cr), | ||
(sy * cp * cr - cy * sp * sr), | ||
(cy * cp * cr + sy * sp * sr) | ||
) | ||
} | ||
fun toQuaternion(euler: EulerRotation, out: Quaternion = Quaternion()): Quaternion = toQuaternion(euler.x, euler.y, euler.z, out) | ||
} | ||
|
||
fun toQuaternion(out: Quaternion = Quaternion()): Quaternion = toQuaternion(this, out) | ||
|
||
fun setQuaternion(x: Double, y: Double, z: Double, w: Double): EulerRotation = Quaternion.toEuler(x.toFloat(), y.toFloat(), z.toFloat(), w.toFloat(), this) | ||
fun setQuaternion(x: Int, y: Int, z: Int, w: Int): EulerRotation = Quaternion.toEuler(x.toFloat(), y.toFloat(), z.toFloat(), w.toFloat(), this) | ||
fun setQuaternion(x: Float, y: Float, z: Float, w: Float): EulerRotation = Quaternion.toEuler(x, y, z, w, this) | ||
|
||
fun setQuaternion(quaternion: Quaternion): EulerRotation = Quaternion.toEuler(quaternion.x, quaternion.y, quaternion.z, quaternion.w, this) | ||
fun setTo(x: Angle, y: Angle, z: Angle): EulerRotation = this | ||
.apply { this.x = x } | ||
.apply { this.y = y } | ||
.apply { this.z = z } | ||
|
||
fun setTo(other: EulerRotation): EulerRotation = setTo(other.x, other.y, other.z) | ||
|
||
private val tempQuat: Quaternion by lazy { Quaternion() } | ||
fun toMatrix(out: Matrix3D = Matrix3D()): Matrix3D = tempQuat.setEuler(this).toMatrix(out) | ||
} |
Oops, something went wrong.