Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / How do i check the distance?

Author
Message
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 8th Jul 2007 16:59 Edited at: 9th Jul 2007 04:12
Hey, how do you do 2d distance checks?

EDIT: AH HA! i figured it out. you use, THE DISTANCE FORMULA!!!
with is D=the square route of x2-x1 squared plus y2-y1 squared!!!!


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 13th Jul 2007 15:22 Edited at: 13th Jul 2007 15:23
You could also use:

disx and y being your distance variables.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Aug 2007 16:59 Edited at: 1st Aug 2007 17:19
@DD
that wouldn't be accurate because if disx=1 and disy=1 then the total distance is 2 but that's incorrect. If you have two axis of distance you are creating a triangle, the actual distance is the hypotenuse but you are adding the other two side lengths.


You work out the hypotenuse by using trigonometry: The square of the Hypotenuse is equal to sum of the squares of the other two sides.
Sure everyone's heard that before



here's a working example


WARNING: When a calculation is likely to return a real number, all variables used in the calculation must real numbers or it wont work in DBC.

Your sig was erased by a mod because it's larger than 600x120
I didn't know about that rule and it was 659 x 126!
Isn't that a little OTT? I'm gonna have to re-make it because of 65 pixels!!!
Dark Dragon
16
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 1st Aug 2007 22:18
that beats the heck out of mine!........-sniff-
flashing snall
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 1st Aug 2007 22:59
does mine work? thats what it said in geometry for dummies!


"these shoes are 300 hundred dollars"-Shoes by Kelly http://smallgroupproductions.com/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Aug 2007 00:02 Edited at: 2nd Aug 2007 00:02
If I've read correctly ours are the same




Be sure to use ABS() as the distance can be in a negative direction. Although knowing the direction can also be useful

Your signature has been erased by a mod because it was rubbish.
Prosaic
17
Years of Service
User Offline
Joined: 5th Aug 2006
Location: Athens
Posted: 2nd Aug 2007 19:31 Edited at: 4th Aug 2007 00:46
Actually dont use ABS if you need to know the direction.and dont use it anyway , it wont hurt in any way.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 4th Aug 2007 17:59
@Prosaic
Thanks for clearing that up, I was trying to say that in the last line lol. But if you want to find out the actual distance between two positions (not the direction) you would use ABS.

Your signature has been erased by a mod because it was rubbish.

Login to post a reply

Server time is: 2024-05-19 07:21:04
Your offset time is: 2024-05-19 07:21:04