aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
index 510b04fb8..1388c076a 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzVec.kt
@@ -6,6 +6,7 @@ import net.minecraft.util.Rotations
import net.minecraft.util.Vec3
import kotlin.math.cos
import kotlin.math.pow
+import kotlin.math.round
import kotlin.math.sin
data class LorenzVec(
@@ -54,6 +55,19 @@ data class LorenzVec(
fun add(other: LorenzVec) = LorenzVec(x + other.x, y + other.y, z + other.z)
+ fun subtract(other: LorenzVec) = LorenzVec(x - other.x, y - other.y, z - other.z)
+
+ fun printWithAccuracy(accuracy: Int): String {
+ val x = (round(x * accuracy) / accuracy)
+ val y = (round(y * accuracy) / accuracy)
+ val z = (round(z * accuracy) / accuracy)
+ return LorenzVec(x, y, z).toCleanString()
+ }
+
+ private fun toCleanString(): String {
+ return "$x $y $z"
+ }
+
companion object {
fun getFromYawPitch(yaw: Double, pitch: Double): LorenzVec {
val yaw: Double = (yaw + 90) * Math.PI / 180