A demo of the atan2() function approach, to calculate the angle between 2 points.

These files might not work on the most current version of the Commander X16, or these may be held over from the previous forum. To find previous versions of the emulator, so you can test old programs, please visit Our GitHub Page
Post Reply
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

A demo of the atan2() function approach, to calculate the angle between 2 points.

Post by svenvandevelde »


Find attached a small demo program that calculates the angle between the middle point of the sceen and the mouse pointer position.




This demo only runs on the R39 emulator version of the cx16.




 




The angle calculated is between 0 and 63, so each quadrant in the circle has 16 different angles (0 to 15).




Please comment to the following article that goes into details on this atan2() approach ...





Sven



Made the logic working on the R38 and R39.


Attachments
cx16-atan2.prg
A demo of the atan2() function approach, to calculate the angle between 2 points.
(2.53 KiB) Downloaded 298 times
KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
Post Reply