Sdcit
2006-03-30 00:22:41
3/29/06
My homework used the Hero’s formula, so I decided to make a script for it :p
What it does: Calculates Area of Triangle given 3 side lengths
Proof:
Script attached, Herons
My homework used the Hero’s formula, so I decided to make a script for it :p
What it does: Calculates Area of Triangle given 3 side lengths
Proof:
We use the formula area = (1/2)bc.sin(A)
And sin(A) = 2 sin(A/2).cos(A/2) so area = bc.sin(A/2).cos(A/2)
Next we find expressions for cos(A/2) and sin(A/2) in terms of
s, a, b, c, where a, b, c are the sides of the triangle and s is
the semi-perimeter.
So s = (a+b+c)/2
b^2 + c^2 - a^2
cos(A) = 2cos^2(A/2) - 1 = ----------------
2bc
b^2 + c^2 - a^2
2cos^2(A/2) = 1 + ------------------
2bc
(b+c)^2 - a^2 (b+c-a)(b+c+a)
= -------------- = --------------
2bc 2bc
(2s-2a)2s
= -----------
2bc
s(s-a)
cos^2(A/2) = ---------
bc
b^2 + c^2 - a^2
Next cos(A) = 1 - 2 sin^2(A/2) = ----------------
2bc
b^2 + c^2 - a^2
2sin^2(A/2) = 1 - ----------------
2bc
a^2 - (b-c)^2 (a-b+c)(a+b-c)
= -------------- = --------------
2bc 2bc
(2s-2b)(2s-2c)
= --------------
2bc
(s-b)(s-c)
sin^2(A/2) = ------------
bc
We can now return to the formula for the area of the triangle:
(1/2)bc.sin(A) = bc.sin(A/2).cos(A/2)
bc.sqrt[s(s-a)(s-b(s-c)]
= ------------------------
bc
= sqrt[s(s-a)(s-b)(s-c)]
Script attached, Herons