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.

Newcomers DBPro Corner / how would i code the distance between 2 objects?

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 30th Sep 2005 01:54 Edited at: 30th Sep 2005 01:56
i mean to check if object 1 is less than certain distance from object 2.


can i have a small example??
Silent Knight
19
Years of Service
User Offline
Joined: 25th Jan 2005
Location: In Your Mind
Posted: 30th Sep 2005 02:22 Edited at: 30th Sep 2005 02:27
here is the distance formula, but it only works if you have x, y, and z formula coordinates of the 2 points

(x[2]-x[1])^2 + (y[2]-y[1])^2 + (z[2]-z(1])^2

then square root that and you have your distance

but putting that into a formula on a program may be fairly hard
The numbers in brackets [] represent the subscript number, the ^ represents that the following number is an exponent

Version--DB Classic
900 mhz AMD Athlon, 128 MB RAM,
16 MB NVidia Vanta gfx card, Windows ME System software
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Sep 2005 03:08 Edited at: 30th Sep 2005 03:09
To calculate the straight line distance in DB between object 'objnum' and the camera use:



The variable Distance contains the distance between camera and object.

If calculating the distance between two objects, then use the other object's X, Y and Z positions instead of the camera's.

TDK_Man

David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 30th Sep 2005 08:01

thankyou silent knight & tdk!!!

works great,thanks
Silent Knight
19
Years of Service
User Offline
Joined: 25th Jan 2005
Location: In Your Mind
Posted: 30th Sep 2005 22:21
although this may not work, it should give you an idea of the distance formula made in BASIC


if i mixed up the way it is then excuse me. although that is not actual code (i dont think), it should show you how you would program the distance formula i posted.

Version--DB Classic
900 mhz AMD Athlon, 128 MB RAM,
16 MB NVidia Vanta gfx card, Windows ME System software

Login to post a reply

Server time is: 2024-11-13 21:17:49
Your offset time is: 2024-11-13 21:17:49