Page 2 of 2
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 7:32 pm
by paul@researchware.com
Well! I was only asking about Rectangles, but, yes it can be done for blobs too
I've closed my un-scientific poll over on the USE-LIST. The consensus is (as Richard chimed in) nearest edges, vertices, or (for blobs) points). While there are certainly a *lot* of ways to figure distance between rectangles, most people apparently do think of distance as being between nearest points. So thank you everyone here and on the USE-LIST for this. Much appreciated.
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 7:53 pm
by richmond62
if you have two weird graphics
Indeed.
But, suppose (just to justify my reputation for being a pain-in-the-bum), you had two amorphous shapes that were NOT graphics:
is there a way one could derive edges based on their transparency thresholds?
-
-
And I don't just suppose, there is any chance of working out how one might trace a PNG image and end up with a vector inwith LiveCode.
The fact that one can do this in Inkscape (an open source program) may point the way to future ideas.
https://inkscape.org/
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 8:18 pm
by SparkOut
Just for the helluvitt (no serious attempt to help here)
A pseudo-method to approximate Richmond's island blobs measurement: (Away in the Western Isles with only a phone, can't see what the stack produces but I suspect it is more to do with edge detection than measurement. )
Measure from the centre of one rectangle or blob to "every" point on the perimeter of the other. For the shortest, note the point on the perimeter of the target shape. Then do the same for the other in reverse. Measure the distance between the two points noted.
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 8:19 pm
by dunbarx
Richmond.
I used curve graphics from the tools palette, which gave me points for free. If you use one of those fancy imported gadgets, I doubt you will find that feature, or rather, property.
You can raster- scan the card window, logging changes in color, and collect those points, but then you need to manage that so only the change from "white-to-color" and "color-to-white" are logged, or you will end up with a LOT of points. This seems simple enough.
Anyway, once you have those points, my handler should work the same.
Craig
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 8:22 pm
by dunbarx
Sparkout.
Measure from the centre of one rectangle or blob to "every" point on the perimeter of the other. For the shortest, note the point on the perimeter of the target shape. Then do the same for the other in reverse. Measure the distance between the two points noted.
See my post just above.
The question is: do these imported blobs have extractable perimeter points? They certainly have a fixed shape, and a computer must need something like those those in order to draw it at all. I am just asking.
Craig
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 8:25 pm
by SparkOut
Er... I see you actually coded my pseudo method. Duh!
Well done. And yes, the question is something completely different now.
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 11:05 pm
by Davidv
Knowing that the question is about how most people might think of the distance between the rectangles, I think my query about overlap still needs an answer. If overlap is permitted, then consider these:

- rectangles.png (6.12 KiB) Viewed 8578 times
If we are discussing edges or vertices then is the second a greater negative offset or similar? Does it depend on a direction of movement before the overlap? Now, centres make more sense. Perhaps it is that we can truncate processing on finding any overlap. It depends on the game or other context.
[No, I was not Finn. I was fast asleep at the time

]
Re: Distance between 2 rectangles.
Posted: Tue Feb 16, 2021 11:21 pm
by bogs
Davidv wrote: Tue Feb 16, 2021 11:05 pm
[No, I was not Finn. I was fast asleep at the time

]
...and I am all of the time, don't let the eyes being open fool you!
Your examples are why I was wondering if it weren't centers being discussed, but apparently they just wanted to know 'what do most people
think your measuring'.
I dunno how you would come up with an answer to that question, short of asking a large % of the world's population what they think.
Re: Distance between 2 rectangles.
Posted: Wed Feb 17, 2021 3:33 am
by dunbarx
Overlaps can be reckoned if you simply remove the "abs" function from my handler. You will then get both positive and negative distances. Negative ones will be overlap distances.
As for what constitutes "closeness", I would bet 99% of the planet would say edges to edges, centers never occurring to anyone at all.
Craig
Re: Distance between 2 rectangles.
Posted: Wed Feb 17, 2021 11:46 am
by bogs
You might bet that, but suspecting something doesn't
prove it.
I might bet that the greater number of people in our country know right from wrong, but visually it appears to be a 50/50 thing, if you see what I mean. I'm pretty sure neither my suspicion nor the visual evidence is conclusive.
Other questions that *might* seem likely bets for the 99% target would be
Whether the earth is spherical
Whether the earth orbits the sun
What comprises true wealth.
I don't know any of those for sure, I only know that people seem to believe one or the other, or in some cases, something completely different

Re: Distance between 2 rectangles.
Posted: Wed Feb 17, 2021 12:09 pm
by Davidv
dunbarx wrote: Wed Feb 17, 2021 3:33 am
Overlaps can be reckoned if you simply remove the "abs" function from my handler. You will then get both positive and negative distances. Negative ones will be overlap distances.
Craig, looking at my image examples, would not your code produce the same number in each case (I haven't tested it), one negative and one positive (or both positive and the same if using abs)?
If we are guessing general views of closeness, then I will conjecture that once overlap occurs, degree of same becomes the highest priority; that is, people would mentally switch from edge closeness to centre closeness. As I said earlier, this may be immaterial. It depends on context.
David