FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   calculating angles... basic trig help
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: calculating angles... basic trig help  (Read 571 times)
aadigi


calculating angles... basic trig help
« on: Mar 13th, 2004, 7:40am »

Hi,
 
I'm trying to wrap my head around some basic trigonometry for a more complex project I'm working on. So I decided to make a really simple visualization of a right triangle that calculated all the angles, but after messing around with atan2() over and over, I'm stumped. I know this is incredibly novice, but I can't get my brain and trigonometry to get along. Any help is much appreciated. The applet I started is here:
http://www.a2l2.com/~aaron/trigDemo/
 
Thanks.
 
-Aaron
 
fry


WWW
Re: calculating angles... basic trig help
« Reply #1 on: Mar 13th, 2004, 8:34pm »

atan2 will return the size of your angle 'a', in radians, which might be what's throwing you off. so your function would look like:
 
float a = degrees(atan2(heightoftriangle, widthoftriangle));
 
the degrees() function converts from radians to degrees, so a will now be in degrees.
 
then, since c will always be 90, so angle b will be 90 - a.
 
i never really got along with trig until i started programming graphics, at which point i found that there are just a few things you have to learn (like how atan2 works) and you'll be set to go.
 
good luck!
 
aadigi


Re: calculating angles... basic trig help
« Reply #2 on: Mar 13th, 2004, 9:02pm »

thanks fry.
actually, in the context of my applet the atan2(heightoftriangle, widthoftriangle) actually gives the angle of angle b.
http://www.a2l2.com/~aaron/trigDemo01/
 
i was a little confused by the example here: http://processing.org/reference/atan2_.html
 
where does using translate() fit in? i guess its not necessary because I got my applet working correctly without it.
 
anyway, thanks for helping me through my trigonometry problem.
 
Pages: 1 

« Previous topic | Next topic »