Title : Distance between 2 squares (2d)
Author : Matthew Smith
Posted : 1+ years ago
Description : Thanks to Jesse and andy_mc for assistance.
Topic: <a href="../Community/posts8a9f.html?topic=90903" target="_blank">http://blitzbasic.com/Community/posts.php?topic=90903[/url] Code : function dist(x1#,y1#,x2#,y2#)
distance# = sqr((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
return distance
end function
OR
d = sqr((x2-x1)^2+(y2-y1)^2)
Comments :
Kryzon(Posted 1+ years ago)
This isn't actually the distance between two squares, but rather two points in a 2D space.The distance between two squares should be computed (if they are not both axis-aligned) by finding which vertex is closer to the other square (so you'll end up with two most closer vertices, one for each square), and getting the distance between these close vertices.