RE: [Flashcoders] Area of a triangle using perimiter values only
>>> 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. Yeah, but then by switching, I'd be insulting the other Mathematician dude who invented divide by 4 equation, just for the sake of pleasing Heron. I dunno. I think I'll have to sleep on it. 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
RE: [Flashcoders] Area of a triangle using perimiter values only
> 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. Without doing the maths, I suspect that eliminating the sin/cos from the two formulas will probably produce Heron's formula in any case. 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
Re: RE: [Flashcoders] Area of a triangle using perimiter values only
ow(b,2)-Math.pow(c,2))/2*a*b); return angle; } else if ( (c == undefined) || (c == null) ) { c = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angleC)); return c; } } // /*** ** * * Method : angleRule * * Refers to the angle rule * angleC + angleA + angleB = 180 * * @param : angleA - the angle opposed to the a side *angleB - the angle opposed to the b side * */ // public static function angleRule(angleA:Number, angleB:Number):Number { var angleC:Number; angleC = 180 - (angleA + angleB); return angleC; } // /*** ** * * Method : area * * Calculates the area of a triangle (best for a rectangle triangle) * A = b*h/2 * * @param : b - the base of the triangle *h - the height of the triangle * */ // public static function area(b:Number, h:Number):Number { var area:Number; area = b*h/2; return area; } // /*** ** * * Method : areaHeron * * Calculates the area of a triangle where s is the triangle's semiperimeter * s = a+b+c/2 * A = sqrt(s(s-a)(s-b)(s-c)) * * @param : a - the a side *b - the b side *c - the c side * */ // public static function areaHeron(a:Number, b:Number, c:Number):Number { var area:Number; area = Math.sqrt((a+b+c)*(a+b-c)*(b+c-a)*(c+a-c))/4; return area; } } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: 14 décembre 2006 14:06 To: Flashcoders mailing list Subject: RE: [Flashcoders] Area of a triangle using perimiter values only Thanks - all, yes Jake saw it first and others chimed in with the same thought, my numbers did not compute because they did not make a triangle. I have it working now. The formula is fine, and this function works for me as long as the values come from a true triangle: 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; } Thanks eveyrone! 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 -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.18/586 - Release Date: 2006-12-13 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.18/586 - Release Date: 2006-12-13 ___ 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
RE: [Flashcoders] Area of a triangle using perimiter values only
) ) { angleC = Math.acos((Math.pow(a,2)+Math.pow(b,2)-Math.pow(c,2))/2*a*b); return angle; } else if ( (c == undefined) || (c == null) ) { c = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(angleC)); return c; } } // /*** ** * * Method : angleRule * * Refers to the angle rule * angleC + angleA + angleB = 180 * * @param : angleA - the angle opposed to the a side *angleB - the angle opposed to the b side * */ // public static function angleRule(angleA:Number, angleB:Number):Number { var angleC:Number; angleC = 180 - (angleA + angleB); return angleC; } // /*** ** * * Method : area * * Calculates the area of a triangle (best for a rectangle triangle) * A = b*h/2 * * @param : b - the base of the triangle *h - the height of the triangle * */ // public static function area(b:Number, h:Number):Number { var area:Number; area = b*h/2; return area; } // /*** ** * * Method : areaHeron * * Calculates the area of a triangle where s is the triangle's semiperimeter * s = a+b+c/2 * A = sqrt(s(s-a)(s-b)(s-c)) * * @param : a - the a side *b - the b side *c - the c side * */ // public static function areaHeron(a:Number, b:Number, c:Number):Number { var area:Number; area = Math.sqrt((a+b+c)*(a+b-c)*(b+c-a)*(c+a-c))/4; return area; } } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: 14 décembre 2006 14:06 To: Flashcoders mailing list Subject: RE: [Flashcoders] Area of a triangle using perimiter values only Thanks - all, yes Jake saw it first and others chimed in with the same thought, my numbers did not compute because they did not make a triangle. I have it working now. The formula is fine, and this function works for me as long as the values come from a true triangle: 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; } Thanks eveyrone! 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 -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.18/586 - Release Date: 2006-12-13 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.18/586 - Release Date: 2006-12-13 ___ 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
Thanks - all, yes Jake saw it first and others chimed in with the same thought, my numbers did not compute because they did not make a triangle. I have it working now. The formula is fine, and this function works for me as long as the values come from a true triangle: 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; } Thanks eveyrone! 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
Re: [Flashcoders] Area of a triangle using perimiter values only
On 12/14/06, T. Michael Keesey <[EMAIL PROTECTED]> wrote: Heron's formula looks pretty simple: Actually, this does return "NaN" for some numbers, but it's pretty simple to realize why. For example, it returns "NaN" if you input side lengths of 1, 2, 4. Why? Well, you try building a triangle with sides of those lengths and let me know how far you get -- T. Michael Keesey The Dinosauricon: http://dino.lm.com Parry & Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ 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
Heron's formula looks pretty simple: function triangleArea(a:Number, b:Number, c:Number):Number { // Check that all arguments are positive and finite. if (!(a > 0) || !(b > 0) || !(c > 0) || !isFinite(a) || !isFinite(b) || !isFinite(c)) { throw new Error("Invalid argument(s) for triangleArea: " + arguments.join(", ")); } // Calculate semiperimeter. var s:Number = (a + b + c) / 2; // Calculate and return area using Heron's formula. return Math.sqrt(s * (s - a) * (s - b) * (s - c)); } -- T. Michael Keesey Director of Technology Exopolis, Inc. 2894 Rowena Avenue Ste. B Los Angeles, California 90039 -- The Dinosauricon: http://dino.lm.com Parry & Carney: http://parryandcarney.com ISPN Forum: http://www.phylonames.org/forum/ ___ 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: Re: [Flashcoders] Area of a triangle using perimiter values only
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
Re: [Flashcoders] Area of a triangle using perimiter values only
Hello Jason, public function getTriangleArea (a:Number, b:Number, c:Number):Number { var p:Number = (a+b+c)/2; return Math.sqrt(p*(p-a)*(p-b)*(p-c)); } -- Ivan Dembicki __ [EMAIL PROTECTED] | http://www.artlebedev.ru | http://www.sharedfonts.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
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
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
Re: [Flashcoders] Area of a triangle using perimiter values only
Hi Jason If the number is coming out negative the most likely reason is that the numbers you are supplying do not make a triangle. (e.g. two sides are length 1 each and the third is 2 or more). I've tested your code and it does produce positive numbers for all valid triangles I've tried. Jake On 14/12/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
RE: Re: [Flashcoders] Area of a triangle using perimiter values only
Without looking up the source of that formula (i.e., just based on what you wrote), I determine this: that in order for the result of multiplication to be negative, one of the terms containing subtraction must be negative. In order for that to occur, one side of your triangle is longer than the sum of the other two. That is impossible. Check your parameters. P. >> -Original Message- >> From: [EMAIL PROTECTED] [mailto:flashcoders- >> [EMAIL PROTECTED] On Behalf Of Jordan Snyder >> Sent: Thursday, December 14, 2006 11:36 AM >> To: Flashcoders mailing list >> Subject: Re: Re: [Flashcoders] Area of a triangle using perimiter values >> only >> >> 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 ___ 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: Re: Re: [Flashcoders] Area of a triangle using perimiter values only
ALL RIGHT I'm a silly billy. I used your code and it works just fine. Maybe the problem isn't in this function. I'm using Flash 8/AS2. Cheers On 12/14/06, Jordan Snyder <[EMAIL PROTECTED]> wrote: 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 -- 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
RE: [Flashcoders] Area of a triangle using perimiter values only
>>To dodge your question, couldn't you just use the simple >>distance forumula to determine the base even when it's not >>horizontal? yes, I could, but again, that's not what I'm after - I want to get the area based on the length of the sides. Thanks though. >>would that not >>indicate a distributive method of multiplication? My brain is even rustier - can you explain? I had thought (a+1)(b+1)(c+1) meant (a+1)*(b+1)*(c+1) but then maybe I'm off? Jason Merrill Bank of America Learning & Organizational Effectiveness >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Jordan Snyder >>Sent: Thursday, December 14, 2006 11:27 AM >>To: Flashcoders mailing list >>Subject: Re: [Flashcoders] Area of a triangle using perimiter >>values only >> >>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 >>___ >>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
> 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
Re: Re: [Flashcoders] Area of a triangle using perimiter values only
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
Re: [Flashcoders] Area of a triangle using perimiter values only
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 ___ 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