Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 3 methods of getting the area of a triangle
- areaOfTriangleHeron a b c = sqrt (s*(s-a)*(s-b)*(s-c)) -- calculate area of a triangle from the length of it's three sides using heron's fomula
- where
- s = (a+b+c) / 2
- areaOfTriangleTrigUnopt a b c = c * height / 2 -- calculate the area of a triangle with modern trigonometry
- where
- cosa = (b^2 + c^2 - a^2) / (2*b*c)
- sina = sqrt (1 - cosa^2)
- height = b*sina
- areaOfTriangleTrig a b c = 0.5 * a * b * sin c -- optimized triangles with trigonometry
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement