On Tue, 11 Apr 2006 21:41:33 +0200, Valentin Schmidt <[EMAIL PROTECTED]>
wrote:
but this means you first have to convert your poibnts to vectors, so it
doesn't make sense if all of the points change all the time.
Hey,
I took Valentin's code and threw in the point to vector conversion just to
see what kind of time that gave but I also changed his long equation for
the distance to a shorter one by storing "a" and "b" instead of
calculating them twice. The results are:
-- "points long equation:"
-- 83
-- "points using variables:"
-- 58
-- "vectors:"
-- 30
-- "pts to vectors:"
-- 116
on test
p1 = point(1,2)
p2 = point(6,10)
put "points long equation:"
ms = the milliseconds
repeat with i = 1 to 50000
dq = (p1[1]-p2[1])*(p1[1]-p2[1]) + (p1[2]-p2[2])*(p1[2]-p2[2])
end repeat
put the milliseconds-ms
p1 = point(1,2)
p2 = point(6,10)
put "points using variables:"
ms = the milliseconds
repeat with i = 1 to 50000
a = p1[1]-p2[1]
b = p1[2]-p2[2]
dq = a*a + b*b
end repeat
put the milliseconds-ms
v1 = vector(1,2,0)
v2 = vector(6,10,0)
put "vectors:"
ms = the milliseconds
repeat with i = 1 to 50000
d = v1.distanceto(v2)
end repeat
put the milliseconds-ms
put "pts to vectors:"
ms = the milliseconds
repeat with i = 1 to 50000
v1 = vector(p1[1], p1[2], 0)
v2 = vector(p2[1], p2[2], 0)
d = v1.distanceto(v2)
end repeat
put the milliseconds-ms
end
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
lingo-l@penworks.com (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]