@Antidote :
That's true, but for 100,000 distance checks using each method. Vectors are without a doubt better. It doesn't matter if the numbers are negative or positive, they're easy to use, and they're always faster. I'm all about more efficient code.
Here's the stress test I did:
sync on : sync rate 60 : autocam off
null=make vector3(3)
make object sphere 1,10
make object sphere 2,10
position object 1,-10,5,20
position object 2,10,20,20
position camera 0,5,-20
sync
length=100000
currentTime=timer()
for i=0 to length
null#=distance1(1,2)
next i
time1=timer()-currentTime
currentTime=timer()
for i=0 to length
null#=distance2(1,2)
next i
time2=timer()-currentTime
currentTime=timer()
for i=0 to length
null#=distance3(1,2)
next i
time3=timer()-currentTime
cls
text 10,10, "Time 1: "+str$(time1)
text 10,30, "Time 2: "+str$(time2)
text 10,50, "Time 3: "+str$(time3)
sync
wait key
rem distance function
function distance1(obj1,obj2)
x1#=object position x(obj1)
y1#=object position y(obj1)
z1#=object position z(obj1)
x2#=object position x(obj2)
y2#=object position y(obj2)
z2#=object position z(obj2)
dist#=sqrt((x1#-x2#)*(x1#-x2#)+(y1#-y2#)*(y1#-y2#)+(z1#-z2#)*(z1#-z2#))
endfunction dist#
function distance2(obj1,obj2)
x1#=object position x(obj1)
y1#=object position y(obj1)
z1#=object position z(obj1)
x2#=object position x(obj2)
y2#=object position y(obj2)
z2#=object position z(obj2)
dist# = sqrt( (x#-dx#)^2 + (y#-dy#)^2 + (z#-dz#)^2 )
endfunction dist#
function distance3(obj1,obj2)
x1#=object position x(obj1)
y1#=object position y(obj1)
z1#=object position z(obj1)
x2#=object position x(obj2)
y2#=object position y(obj2)
z2#=object position z(obj2)
set vector3 3,x1#-x2#,y1#-y2#,z1#-z2#
dist#=length vector3(3)
endfunction dist#
Distance 1 : 122 ms
Distance 2 : 110 ms
Distance 3 : 84 ms
@GMX - good work. I'm sure we'll see some great things coming from you soon.