trigonometry c++
hey,
given one side and an angle how do you calculate the other sides and angles in a right angle triangle in c++.
I'm basically looking for an algorithm.
Thanks
drjay
drjay1627
Junior Poster in Training
91 posts since Nov 2008
Reputation Points: 12
Solved Threads: 1
Well if you have idea about math, You can write the implementation itself by using the angles and the functions "sin , cos , tan etc. " Provided in the c++ math library.
And if you wish to get yourself a algorithm i suggest you try googling it up.
Sky Diploma
Practically a Posting Shark
865 posts since Mar 2008
Reputation Points: 673
Solved Threads: 131
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
thanks...
how do you print 90 degrees?
side2 = (side1) / (tan(angle1*PI/180));
side3 = (side1) / (sin(angle1*PI/180));
angle2 = (atan (side2/side1) * 180 / PI);
angle3 = (asin (side3/side1) * 180 / PI);
output:
for 90 degree angle i get a weird output:
-1.#IND
instead of 90, can someone please help me!
drjay
drjay1627
Junior Poster in Training
91 posts since Nov 2008
Reputation Points: 12
Solved Threads: 1
You are aware that tan(90) [in degree] is infinity, and obviously, so is tan(pi/2) [in radians] as pi/2 radians == 90degrees.
That is easy to see if you consider that tan is the ration of the length of the two shorter sides on a right angled triangle. Ie by the time the angle nearly 90 degrees the other angle in the triangle is very small. Try drawing that and you will see that you are rapidly getting to LOTS/(Near Zero).
StuXYZ
Practically a Master Poster
680 posts since Nov 2008
Reputation Points: 760
Solved Threads: 138