Jason, It must be true that your inputs are incorrect, BUT to answer your question about distributive methods - I was just thinking about condensing that formula. If you did that(and they do it in the next step on the MathWorld link) then you have to multiply every term in parens by every other term in parens and you get all of that whacky a^4, b^4 business. As it is, you're supplying your function with the values of a, b, and c, so you can add them in the parens and multiply out the whole numbers. False alarm there!
Cheers On 12/14/06, Nex Ninek <[EMAIL PROTECTED]> wrote:
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
-- Jordan Snyder Applications Developer Image Action LLC http://www.imageaction.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