May 07, 2024, 10:27:25 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Arctan(x,y) DLL

Started by GWS, February 26, 2008, 12:27:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Here's another little routine which I always have to scratch my head about to get the angles correct ..  :)

This is a version of the trigonometry function ArcTan(x,y) which takes two decimal arguments of points in the x - y plane, and calculates the full angle in degress, clockwise from the 12 o'clock position.

(If you want to put integer x,y values into it (as for screen co-ordinates, remember to define the variables x,y as Float - then it's happy if you just enter integers.  If you forget this, you'll get weird answers.  :))

This also relates to the complex number Argand diagram, where z = (x + iy) = |z| * exp(iΘ) and |z| = sqrt(x^2+y^2))

Θ is the angle given by this routine in degrees ..


Attached is the DLL 'argxy.dll', a small test program, and the EBasic code for the dll ..


all the best, :)

Graham
Tomorrow may be too late ..