I recind half of what I said after actually thinking about it, but maybe it's a different perspective ;)
On 12/14/06, Jordan Snyder <[EMAIL PROTECTED]> wrote:
To dodge your question, couldn't you just use the simple distance forumula to determine the base even when it's not horizontal? I dont' know much about your application or if you'll have the points where the triangle's points lie, but that's just an idea. Oh, but I just thought of something from my old rusty brain. I looked at the formula on the mathworld page; would that not indicate a distributive method of multiplication? Again, rusty, but a thought. Let us know what you figure out!! Cheers 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 > -- Jordan Snyder jordansnyder.com Applications Developer Image Action LLC http://www.imageaction.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