Monday, December 3, 2012

Triangle Area...

Continuing on with the calculating of area... lets look at triangles.
 There are tons of ways to get the area of a triangle so.....

Here is a link to wikipedia's section on Triangles .

I went with Heron's Formula, simply because I had all the edge/side lengths worked out already. Here is what my scene looks like...

Heron's formula in softimage ICE
*click to make bigger*

I drew a linear curve with three points for my triangle.

The black value(area=√( s(s-a)(s-b)(s-c) )) is the area of the triangle, the orange value(cos C = (a^2 + b^2 - c^2)/2ab) is the corner angle of Point_02_Null. The light green value(s = (a+b+c)/2) is half the length of the perimeter of the triangle.

Lets go look at all this in ICE.

To start I made a little cluster to null constraint so I could move the triangle points around freely. I named them Point_01_Null, Point_02_Null and Point_03_Null. *something to keep in mind is that one of your points will be numbered 0, and be on 0,0,0. I just moved mine off the origin. In the wikipedia they go into a whole section on this.*

Null Constraint In ICE Softimage

Point Nulls 01,02,03

Here's what that constraint looked like in ICE.

Cluster to Null ICE/Softimage

Then I worked out the length and center of the three sides.

Edges of a triangle in Softimage

Side A, B and C letters where stuck too the curve by a standard Softimage constrain between two points.

Center of side

Using a linear blend between the two nulls was the fastest why to get the center point on the curves

Linear Blend Between two nulls in ICE

Using the distance between node, I got all three sides lengths and then added them together to get the perimeter of the whole triangle.

Length of three sides of a triangle in softimage/ice

curve length of a triangle

Here's what the inside of the compound "length of C" looks like....

Length of three sides of a triangle in ICE

Next I tested the side lengths with the curve length to see if the perimeters matched up.

perimeter length of a triangle

Now I could work out the angles of the triangle using the law of cosin:

cos C = (a^2 + b^2 - c^2)/2ab

the law of cosin in Softimage

Here's what the ICE tree looks like...
 *note I had the to use ArcCos to get the right answer*

law of cosin in ICE

Last I worked out the Area of my triangle using Herons Formula.

Herons formula for area in softimage

This formula has two parts to it, the first being:
(s = (a+b+c)/2   which gets half of the perimeter, and then
 area=√( s(s-a)(s-b)(s-c) ) which uses the value s to work out the area.

Herons formula for area in ICE

Here's what those two sums look like....


Taking the ready made side lengths(A, B and C) and subtract the value s from them. Multiply those answers with the value s. Then all thats left is to get the square root of that and you have the area of the triangle.

the area of a triangle in softimage


No comments: