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 / Inverse Tangent - How?

Author
Message
RossMills
20
Years of Service
User Offline
Joined: 3rd Apr 2004
Location:
Posted: 4th Apr 2004 06:48
This probably seems mundane... but I even asked the creator of DarkBASIC at the Uni and he didn't know...

So I was hoping a coder from here knew how to make an inverse tangent of a given number in DarkBASIC.

Thanks if you can.

Ross
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 4th Apr 2004 08:27
You use the atan() function which is the same as an inverse tangent.
And you use acos() for inverse cosine and asin() for inverse sine.

Hope this helped.
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Apr 2004 09:19
I dunno about DBPro, but DBC doesn't have atan, acos, and asin...

But remember the following:

Sine= Opposite/Hypotenuse
Cosine=Adjacent/Hypotenuse
Tangent=Opposite/Adjacent

To find the inverse of sin, multiply what you get out of sin() by the hypotenuse.

To find the inverse of cos, multiply what you get out of cos() by the hypotenuse.

To find the inverse of tan, multiplay what you get out of tan() by the adjacent.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 4th Apr 2004 09:25 Edited at: 4th Apr 2004 09:26
My DBC has those commands. It's version 1.12. I tried it just a minute ago. I typed Print atan(1) and it showed 45.0085(I don't know why, it should be a precise 45 )
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Apr 2004 09:26
Awesome! You have my deepest gratitude, hyrichter.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 4th Apr 2004 09:28
Thanks, but does anyone know why my computer gives 45.0085 for the inverse tangent of 45? Is it just a minor bug with DBC?
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Apr 2004 09:33
Hmmm.........I know tan(45) is 1. It's probably just the way the processor handles the math routines, same answer comes up when I run it. Integer truncating should help with that, since 99% of the time when dealing with trig you need your degrees values as ints.

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Apr 2004 13:52
No, it's not a bug. It's a limitation of the floating point system used by the processor, combined with compressing the floats to 4 bytes from the 10 it uses internally.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 4th Apr 2004 22:29
Thanks boatloads for the enlightenment IanM

Crazy Donut Productions, Current Project: KillZone
Web Site Button Does Not Work, Visit Here: http://www.geocities.com/crazydonutproductions/index.html

Login to post a reply

Server time is: 2024-11-26 12:38:40
Your offset time is: 2024-11-26 12:38:40