Normalize angle reference system
Normalize all angles to the same reference system. Now some angles (robot.angle) points to the top of the screen when its value is 0 and others point to the left (robot.cannonAbsoluteAngle). Also, some are in the 0..360 range, but others are in -180..180
We are sorry for not having fixed it yet, but it will break many robots. That’s why we are waiting for a better opportunity to fix it.
it WILL not break other robots. As said, and as common sense dictates, just mark the current vars as deprecated, and add new normalized variables.
Ivan S commented
Normalizing angle system is an excellent way to filter out an ENORMOUS number of clones/copies.
Original authors will update their robots, clones will go down the rank ladder.
Toni Uebernickel commented
I don't see why this is required.
The range of -180..180 degrees is actually reasonable when representing the bearing between two objects.
The gun of a robot is just another object which support point is on the robot itself. Thus having -135 degrees (pointing rear left) or 135 degrees (pointing rear right) is perfectly fine.
It's much more descriptive than having the range of 0..360!
Egor Saveiko commented
This could be fixed without breaking backward compatibility adding alternative vars with normalized angles relative to one angle start. old robots will work, but new can be write in new angles:
Smth like this:
robot.log("CAA Normalized:" + robot["cannonAbsoluteAngleN"]); //see N in the end of var
robot.log("CRA Normalized:" + robot["cannonRelativeAngleN"]);
robot.log("RA Normalized:" + robot["angleN"]);
Or players can add some normalization functions like
//change degree start from 0 to 90 (90 will be 0, 180 - 90, 270 - 180, 360 - 270)
A -= 90;
if(A < 0) A+=360;
Matthew Bellantoni commented
I couldn't find this documented anywhere. Is it? This consumed about an hour of my time.
ev.bearing of the onWallCollision event seems flipped to me. It returns the relative angle of the robot in reference to the wall, not the other way around as I think it should be. The bearing of onHitByBullet is correct, though.
Fredrik Håård commented
I'd suggest keeping the current method as-is, document that it is broken and deprecated, and add another one with a different name to authors can migrate their bots without breaking.
I made a little app that helps visualizing all those angles:
Wouldn't mind if there was a way to draw own helper lines and circles in the editor, would help me a lot.
Phil D. commented
I'm curious how this could be fixed without breaking backward compatibility.
Also consider atan2, sin, cos,..
Makes sense... We'll tackle that asap. Thanks for your report.