CC: Tweaked

CC: Tweaked

59M Downloads

`atan2` works incorrectly

Renegatto opened this issue ยท 3 comments

commented

Minecraft Version

1.20.1

Version

1.113.0

Details

atan2 returns incorrect results, different from a results of a standalone lua (and from online calculators).

Expected behavior

Checked with my local lua v5.3.6 and in online caluclators, all agree with this:

atan2(0.72999052539834, -0.68345726481518) -- returns 2.3232845658174

Actual behavior

While in CC: Tweaked I get this:

atan2(0.72999052539834, -0.68345726481518) -- returns 0.63057157635225
commented

Thanks for the report. I'm afraid I'm not able to reproduce this at all โ€” I get the same result as expected.

image

This is very odd, as CC's Lua VM just uses Java's built-in atan2 implementation, so you'd expect this to be correct! Would you be able to upload your logs? Just in case you're running an odd JVM version or something.

commented

You called atan, not atan2: (from qalc)

> atan(0.72999052539834, -0.68345726481518)

  warning: Additional arguments for function arctan() were ignored. Function can only use 1 argument.
  arctan(0.72999052539834) โ‰ˆ 0.6305715764

Lua ignores excessive arguments.

commented

You called atan, not atan2: (from qalc)

> atan(0.72999052539834, -0.68345726481518)

  warning: Additional arguments for function arctan() were ignored. Function can only use 1 argument.
  arctan(0.72999052539834) โ‰ˆ 0.6305715764

Lua ignores excessive arguments.

You are right, that was atan in both cases, not atan2.
I've missed the fact that Lua 5.3 transition

math.atan2 -> math.atan

is not supported in CC:Tweaked.

Anyway, there is no bug, thanks! ๐Ÿ‘