Help with Triangles
I''m trying to write a program for my college computer science class. I''m pretty stumped. I need to figure out how to get the area of a triangle, of any type, just knowhing the length of the three sides... thanks.
February 28, 2002 08:55 PM
Get out your nearest trig book or Google search for "area of triangle" and I bet you''ll finish this before anyone else can reply.
You need Hero''s Formula, which is pretty easy to implement:
n = (perimeter of triangle) / 2;
Area = sqrt( n*(n - side1)*(n - side2)*(n - side3) );
A quick example (3-4-5 right triangle):
n = (3 + 4 + 5)/2 = 12/2 = 6
sqrt( 6(3)(2)(1) ) = sqrt(36) = 6
And, lo and behold, (3*4)/2 = 6 as well![](smile.gif)
I hope that helps!
n = (perimeter of triangle) / 2;
Area = sqrt( n*(n - side1)*(n - side2)*(n - side3) );
A quick example (3-4-5 right triangle):
n = (3 + 4 + 5)/2 = 12/2 = 6
sqrt( 6(3)(2)(1) ) = sqrt(36) = 6
And, lo and behold, (3*4)/2 = 6 as well
![](smile.gif)
I hope that helps!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement