diff options
author | nea <nea@nea.moe> | 2023-05-07 12:22:36 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-08 00:17:34 +0200 |
commit | 942dd629efbf12183b1c5f5a966c36d4b0647a6b (patch) | |
tree | 407e8d2cdcfefa77673c768e5126857a86ddb89a /src/test/kotlin/AngleTest.kt | |
parent | 229f724ef4a0a4cbc426f31e27f9a57e9b1307c9 (diff) | |
download | Firmament-942dd629efbf12183b1c5f5a966c36d4b0647a6b.tar.gz Firmament-942dd629efbf12183b1c5f5a966c36d4b0647a6b.tar.bz2 Firmament-942dd629efbf12183b1c5f5a966c36d4b0647a6b.zip |
Add fishing particle highlighter
Currently does not work when sneaking or when the bobber moves too much, since the position desyncs with the server
Diffstat (limited to 'src/test/kotlin/AngleTest.kt')
-rw-r--r-- | src/test/kotlin/AngleTest.kt | 28 |
1 files changed, 28 insertions, 0 deletions
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())}") + } + } +} |