Re: [Flashcoders] calculating distance between two points
Point.distance (like pretty much all Flash math functions) is abysmally slow and shouldn't be used in anything performance-critical. Write your own replacement (using formula provided above) if you're doing a bunch of these every frame. On 3/11/08, Kenneth Kawamoto <[EMAIL PROTECTED]> wrote: > Isn't it pointless to do Math.abs() since result is always positive > number anyway? ;) > > > Kenneth Kawamoto > http://www.materiaprima.co.uk/ > > > Paul Andrews wrote: > > - Original Message - From: "Merrill, Jason" > > <[EMAIL PROTECTED]> > > To: "Flash Coders List" > > Sent: Tuesday, March 11, 2008 1:53 PM > > Subject: RE: [Flashcoders] calculating distance between two points > > > > > >>>> Your teacher must be cringing! > >>>> > >>>> "The square of the hypotenuse equals the sum of the squares of the > >>>> opposite two sides" should be familar.. ;-) > >>>> > >>>> Math.sqrt ( Math.pow(Math.abs(x1-x2),2 )+Math.pow(Math.abs(y1-y2),2 > >>>> )+)) > >> > >> > >> Why not skip the math lessons and use the Point class? > > > > Yes, my explanation was what was completely pointless.. > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Cory Petosky : Lead Developer : PUNY 1618 Central Ave NE Suite 130 Minneapolis, MN 55413 Office: 612.216.3924 Mobile: 240.422.9652 Fax: 612.605.9216 http://www.punyentertainment.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
Isn't it pointless to do Math.abs() since result is always positive number anyway? ;) Kenneth Kawamoto http://www.materiaprima.co.uk/ Paul Andrews wrote: - Original Message - From: "Merrill, Jason" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Tuesday, March 11, 2008 1:53 PM Subject: RE: [Flashcoders] calculating distance between two points Your teacher must be cringing! "The square of the hypotenuse equals the sum of the squares of the opposite two sides" should be familar.. ;-) Math.sqrt ( Math.pow(Math.abs(x1-x2),2 )+Math.pow(Math.abs(y1-y2),2 )+)) Why not skip the math lessons and use the Point class? Yes, my explanation was what was completely pointless.. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
- Original Message - From: "Merrill, Jason" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Tuesday, March 11, 2008 1:53 PM Subject: RE: [Flashcoders] calculating distance between two points Your teacher must be cringing! "The square of the hypotenuse equals the sum of the squares of the opposite two sides" should be familar.. ;-) Math.sqrt ( Math.pow(Math.abs(x1-x2),2 )+Math.pow(Math.abs(y1-y2),2 )+)) Why not skip the math lessons and use the Point class? Yes, my explanation was what was completely pointless.. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] calculating distance between two points
That was the one I thought I'd heard of. But... Too easy! Boring! Soh cah toa ! (and that as far as I can remember is actually the only useful thing I did learn in school) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ivan Dembicki Sent: 11 March 2008 12:35 To: [EMAIL PROTECTED]; Flash Coders List Subject: Re: [Flashcoders] calculating distance between two points Or you can use new revolutionary Point.distance(pt1, pt2); -- iv http://www.bezier.ru http://bezier.googlecode.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders __ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. __ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
aargh that pun made me bleed On 11 Mar 2008, at 14:24, Piers Cowburn wrote: Good point On 11 Mar 2008, at 13:53, Merrill, Jason wrote: Why not skip the math lessons and use the Point class? var dist:Number = Point.distance(p1, p2); Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GT&O Innovative Learning Blog & subscribe. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders [EMAIL PROTECTED] 0207 631 3278 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] calculating distance between two points
Very punny. Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GT&O Innovative Learning Blog & subscribe. >>-Original Message- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Piers Cowburn >>Sent: Tuesday, March 11, 2008 10:24 AM >>To: Flash Coders List >>Subject: Re: [Flashcoders] calculating distance between two points >> >>Good point >> >> >>On 11 Mar 2008, at 13:53, Merrill, Jason wrote: >>>>> >>> >>> >>> Why not skip the math lessons and use the Point class? >>> >>> var dist:Number = Point.distance(p1, p2); >>> >>> >>> Jason Merrill >>> Bank of America >>> GT&O L&LD Solutions Design & Development eTools & Multimedia >>> >>> Bank of America Flash Platform Developer Community >>> >>> >>> Are you a Bank of America associate interested in >>innovative learning >>> ideas and technologies? >>> Check out our internal GT&O Innovative Learning Blog & subscribe. >>> >>> >>> >>> ___ >>> Flashcoders mailing list >>> Flashcoders@chattyfig.figleaf.com >>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >>[EMAIL PROTECTED] >>0207 631 3278 >> >> >>___ >>Flashcoders mailing list >>Flashcoders@chattyfig.figleaf.com >>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
Good point On 11 Mar 2008, at 13:53, Merrill, Jason wrote: Why not skip the math lessons and use the Point class? var dist:Number = Point.distance(p1, p2); Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GT&O Innovative Learning Blog & subscribe. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders [EMAIL PROTECTED] 0207 631 3278 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] calculating distance between two points
>>Your teacher must be cringing! >> >>"The square of the hypotenuse equals the sum of the squares >>of the opposite two sides" should be familar.. ;-) >> >>Math.sqrt ( Math.pow(Math.abs(x1-x2),2 >>)+Math.pow(Math.abs(y1-y2),2 )+)) Why not skip the math lessons and use the Point class? var dist:Number = Point.distance(p1, p2); Jason Merrill Bank of America GT&O L&LD Solutions Design & Development eTools & Multimedia Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GT&O Innovative Learning Blog & subscribe. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
Aha - didn't know about that! Paul - Original Message - From: "Ivan Dembicki" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; "Flash Coders List" Sent: Tuesday, March 11, 2008 12:34 PM Subject: Re: [Flashcoders] calculating distance between two points Or you can use new revolutionary Point.distance(pt1, pt2); -- iv http://www.bezier.ru http://bezier.googlecode.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
Using Point class? import flash.geom.Point; var p0:Point = new Point(0, 0); var p1:Point = new Point(1, Math.sqrt(3)); var nDistance:Number = Point.distance(p0, p1); trace(nDistance); // Output: 2 _ Jim Hayes wrote: I think there may be an inbuilt method in flash, mind you, but if there is I don't know what it is. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lehr, Theodore M (N-SGIS) Sent: 11 March 2008 12:05 To: Flash Coders List Subject: [Flashcoders] calculating distance between two points How do you calculate the distance between two points with different x and y values? I know it is some simple math formula - I just don't know it -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
Your teacher must be cringing! "The square of the hypotenuse equals the sum of the squares of the opposite two sides" should be familar.. ;-) Math.sqrt ( Math.pow(Math.abs(x1-x2),2 )+Math.pow(Math.abs(y1-y2),2 )+)) Paul - Original Message - From: "Lehr, Theodore M (N-SGIS)" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Tuesday, March 11, 2008 12:05 PM Subject: [Flashcoders] calculating distance between two points How do you calculate the distance between two points with different x and y values? I know it is some simple math formula - I just don't know it ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] calculating distance between two points
Pythagorus, innit? The square root of the the sum of the difference in x squared and the difference in y squared ? Or was I not listening in school way back then? I think there may be an inbuilt method in flash, mind you, but if there is I don't know what it is. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lehr, Theodore M (N-SGIS) Sent: 11 March 2008 12:05 To: Flash Coders List Subject: [Flashcoders] calculating distance between two points How do you calculate the distance between two points with different x and y values? I know it is some simple math formula - I just don't know it ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders __ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. __ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] calculating distance between two points
The square root of the sum of the squares of the x difference and the y difference. Pythagoras -Original Message- How do you calculate the distance between two points with different x and y values? I know it is some simple math formula - I just don't know it ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Thomson Scientific Limited is a company incorporated under the laws of England and Wales (registered number 756619) having its registered office and address for service at Aldgate House, 33 Aldgate High Street, London, EC3N 1DL This email is for the sole use of the intended recipient and contains information that may be privileged and/or confidential. If you are not an intended recipient, please notify the sender by return email and delete this email and any attachments. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
Or you can use new revolutionary Point.distance(pt1, pt2); -- iv http://www.bezier.ru http://bezier.googlecode.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
dx:Number = obj1.x - obj2.x; dy:Number = obj1.y - obj2.y; distance:Number = Math.sqrt(dx * dx + dy * dy); On Tue, Mar 11, 2008 at 8:05 AM, Lehr, Theodore M (N-SGIS) < [EMAIL PROTECTED]> wrote: > How do you calculate the distance between two points with different x > and y values? I know it is some simple math formula - I just don't know > it > ___ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- Anthony Cintron Flash || Flash Developer www.sweetiesandgangsters.com [EMAIL PROTECTED] ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] calculating distance between two points
You can use our old friend Pythagoras': c^2 = a^2 + b^2 Kenneth Kawamoto http://www.materiaprima.co.uk/ Lehr, Theodore M (N-SGIS) wrote: How do you calculate the distance between two points with different x and y values? I know it is some simple math formula - I just don't know it ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] calculating distance between two points
How do you calculate the distance between two points with different x and y values? I know it is some simple math formula - I just don't know it ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders