Collision detection: a comparison.
dsc at swcp.com
Wed Oct 2 09:33:01 EDT 2002
On Monday, September 30, 2002, at 01:35 AM, malte brill wrote:
> That sounds very interesting, as it is what I am trying to do. Do
> you mind
> giving me some pseudo-code, as I still loose hair on it.
OK. You caught me at a time when I'm up to my neck in alligators,
but I'm pleased to give it a try.
> How would I define
> these rectangles for usage with the pixel method?
Define them relative to the image to which they apply. Use the Rev
way to represent rectangles (left, top, right, bottom); see the
rectangle property. I think the Rev origin is the upper left.
Consider this to be a pair of points or vectors. Represent a list
of rectangles as a rectangle in each line.
> I still haven´t been
> working much with custom properties, and I think I still don´t get
> the idea.
Others can better advise you.
Every image has a list of subrects such that they (typically) do
not overlap and they approximate the shape of the picture in the
Two images overlap pictures if their rectangles overlap and they
overlap internally. (Test that "their rectangles overlap" first
and return false if false.)
Two images overlap internally if any subrect of the second,
converted to the coordinate system of the first, overlaps with any
subrect of the first. (Optional: ...and the two subrects have a
The subrectable of one image converted to the coordinate system of
another image is its rectangle with each corner increased by the
offset of the second image to the first.
The offset of one image to another is its reference corner less
that of the other. (I think the corner is left, top.)
Two rectangles overlap if the max of the tops is less than the min
of the bottoms and the max of the lefts is less than the min of the
A subrect of one image and the subrect of another image have a
pixel overlap if... (left to later; needed only if optional part
above is used)
I hope this helps; it seems to be more pseudo than code.
More information about the use-livecode