From 942dd629efbf12183b1c5f5a966c36d4b0647a6b Mon Sep 17 00:00:00 2001 From: nea Date: Sun, 7 May 2023 12:22:36 +0200 Subject: Add fishing particle highlighter Currently does not work when sneaking or when the bobber moves too much, since the position desyncs with the server --- src/test/kotlin/AngleTest.kt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/kotlin/AngleTest.kt (limited to 'src/test/kotlin') diff --git a/src/test/kotlin/AngleTest.kt b/src/test/kotlin/AngleTest.kt new file mode 100644 index 0000000..4be6086 --- /dev/null +++ b/src/test/kotlin/AngleTest.kt @@ -0,0 +1,28 @@ +import kotlin.math.atan + +private fun calculateAngleFromOffsets(xOffset: Double, zOffset: Double): Double { + var angleX = Math.toDegrees(Math.acos(xOffset / 0.04f)) + var angleZ = Math.toDegrees(Math.asin(zOffset / 0.04f)) + if (xOffset < 0) { + angleZ = 180 - angleZ + } + if (zOffset < 0) { + angleX = 360 - angleX + } + angleX %= 360.0 + angleZ %= 360.0 + if (angleX < 0) angleX += 360.0 + if (angleZ < 0) angleZ += 360.0 + var dist = angleX - angleZ + if (dist < -180) dist += 360.0 + if (dist > 180) dist -= 360.0 + return angleZ + dist / 2 +} + +fun main() { + for(i in 0..10) { + for (j in 0..10) { + println("${calculateAngleFromOffsets(i.toDouble(),j.toDouble())} ${atan(i.toDouble() / j.toDouble())}") + } + } +} -- cgit