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: 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: 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: [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: RE: [Flashcoders] Area of a triangle using perimiter values only
)-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