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.

DarkBASIC Discussion / Need a snippet

Author
Message
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 18th Jul 2003 22:21
i need a code that calcualtes the distance between 2 objects in dbc. (actaly i probly have this in a tutorial somewere but im too lazy to dig it up)
As I walk through the vally of the shadow of death, I will fear no evil.
- Psalms 23:4
Hamish McHaggis
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 19th Jul 2003 00:23 Edited at: 19th Jul 2003 00:25
x1#,y1# and z1# are the coordinates for the first object, and x2#,y2# and z2# are the coordinates for the second object. This is called pythagoruses theorum, it works in 3d aswell as 2d (2d you just use x# and y#)...

dist# = sqrt((x1# - x2#)^2 + (y1# - y2#)^2 + (z1# - z2#)^2)

BTW, pythagoruses theorum states that the on any right angled triangle, the square of the hypotinuse (the longest side, or the one opposite to the right angle) is equal to the sum of the squares of the other two sides.

z^2 = y^2 + x^2
     or
z = sqrt(y^2 + x^2)


Diagram.... 1 is the first object, 2 is second object.


Thats in 2D, I couldn't draw 3D but that is the same, just an extra component...

w^2 = x^2 + y^2 + z^2
       or
w = sqrt(x^2 + y^2 + z^2)

cuRant PRogekt: a three-de map editer
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 19th Jul 2003 01:27
scary. Are you a math major like my dad or somethin!

---Mattman
DID YOU KNOW THAT ???
Blazer
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: United States
Posted: 19th Jul 2003 02:41
*slaps his head* i learned this in math about 4 monthes ago. Thx for help, but how do I do square root in basic

As I walk through the vally of the shadow of death, I will fear no evil.
- Psalms 23:4
Drifter
21
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 19th Jul 2003 06:15
I'm 12 and I know that! lol

"Sun makes me sneeze but thats a different story"
Devil Master
21
Years of Service
User Offline
Joined: 16th Jul 2003
Location:
Posted: 19th Jul 2003 10:29
Quote: "Thx for help, but how do I do square root in basic"

With the Sqrt() function, like Hamish McHaggis did in his formula.

Hamish McHaggis
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 19th Jul 2003 17:14
Doh! Well hopefully I helped someone else who read the post.

Now drop and give me 20 prime numbers Mattman!!!

cuRant PRogekt: a three-de map editer
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM

Login to post a reply

Server time is: 2025-05-19 10:17:38
Your offset time is: 2025-05-19 10:17:38