Re: [Flashcoders] Area of a triangle using perimiter values only

2006-12-14 Thread Nex Ninek

I'd stick to using Heron's rule -- there is no reason why it shouldn't work
given correct inputs, and it is less expensive computationally.

On 12/14/06, Danny Kodicek <[EMAIL PROTECTED]> wrote:


> I'm trying to figure the area of a triangle in Actionscript
> using the perimeter values only, not the traditional simple formula:
>
>  area = (height/2)*base

Try: area = 1/2 * a * b * sin(C), where C is the angle between the two
sides
a and b. You can calculate C using the cosine rule: c^2 = a^2 + b^2 - 2ab
*
cos(C). A bit of manipulation will give you sin(C) in terms of cos(C) so
you
can avoid using any trig (sorry I have to rush so I don't have time to do
it
right now)

HTH
Danny

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] Area of a triangle using perimiter values only

2006-12-14 Thread Nex Ninek

Negative result of ((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)) is not possible if a,b,
and c are lengths of a triangle's sides.  The first term will always be
obviously positive, and so will the other three terms -- they  are simply
the sum of  the lengths of two sides less the third side, and you can't have
a triangle where that isn't true.  It's most likely that your input numbers
to the formula are incorrect.  Trace that to find your problem.

On 12/14/06, Merrill, Jason <[EMAIL PROTECTED]> wrote:


I'm trying to figure the area of a triangle in Actionscript using the
perimeter values only, not the traditional simple formula:

 area = (height/2)*base

because figuring the height is tricky given the triangle will be drawn
in odd ways (i.e. a not horizontally alinged base), so I am exploring
other triangle area forumulas that only take in the perimiter values
(a,b,c), like Heron's formula or this one, which I like:

given a,b,c are the length of the sides of the triangle, then the
formula is:

   squareRoot of: (a+b+c)(b+c-a)(c+a-b)(a+b-c)
___
 4

So in trying to translate that to actionscript, I wrote:

public static function areaOfTriangle(a:Number, b:Number,
c:Number):Number{
return (Math.sqrt((a+b+c)*(b+c-a)*(c+a-b)*(a+b-c)))/4;
}

But the problem is (a+b+c)*(b+c-a)*(c+a-b)*(a+b-c) results in a negative
number, and this the square root cannot be taken.  Or perhaps I am
interpreting the forumula incorrectly:
http://mathworld.wolfram.com/TriangleArea.html

What am I doing wrong here?  Thanks.

Jason Merrill
Bank of America
Learning & Organizational Effectiveness




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com