Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / DBC enhanced - atan and atanfull seem to be giving the complimentary angles to the same slope

Author
Message
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Sep 2006 13:45
I wrote this bit of code to test various angles because I was trying different methods of reflection. It seems that when I calculate the slope then take the arctangent of that, it gives the angle I would expect.

When I use atanfull, I get the complimentary angle. Is it my code, or the functions atan and atanfull?

Just click in a quadrant and a line will be drawn and the angle of the line displayed in the upper left.



Enjoy your day.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Sep 2006 12:45
Its your method that's incorrect. If you move the line in a circle, you will see the jump in angle when going from right to left quandrants. According to your slope method, 270 and 90 (i wrapped the values) are basically in the same spot. There's a 180 degree jump when switching sides.



"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Sep 2006 21:12 Edited at: 6th Sep 2006 01:53
Thank you for your help.

I guess what I'm seeing and what I keep running into problems with, is the direction angles open. The atan() function calculates angles starting from the positive horizontal and increases as the angle opens counter clockwise.

The atanfull() function calculates angles starting from the positive vertical and increases as the angle opens clockwise. Your example function also calculates clockwise starting from positive vertical.

Maybe I'm missing something, but using any of the inverse trig functions gives back the counter clockwise angle, and using atanfull gives back the clockwise angle. Here's an example:



Thanks in advance for any help.

[Edit]

I think I got it. I've been reviewing the library function atan2(y,x) and believe DarkBASIC's equivalent is atanfull(). In C, atan2() takes the y input before the x input. When I use this method in DBC, I get the angles I expect - opening counter clockwise and matching the other inverse trig functions.

Though the DBC manual states:



I will use Return Value=ATANFULL(Distance Y, Distance X). Any opinions on this?

Enjoy your day.

Login to post a reply

Server time is: 2024-11-26 11:54:52
Your offset time is: 2024-11-26 11:54:52