[squeak-dev] What it is the expected behavior of Rectangle (class) #intersect: if there is no interesection?

karl ramberg karlramberg at gmail.com
Fri Dec 2 06:33:46 UTC 2022


I was just dabbing on something kind of similar for a Conway's game of life
program.
I want to select a part of the matrix to copy or move etc.
Here is a small morph I made to test out selecting.
I don't know if this is useful for you  :-)

Best,
Karl


On Thu, Dec 1, 2022 at 11:34 PM LawsonEnglish <LEnglish5 at cox.net> wrote:

> Thanks.
>
> I think I figured out the simplest way to do things. Morphle Logic cells
> are always squares the same size, so rather than try to go by testing
> whether not a rectangle selected morphs by testing their bounds directly,
> I'll use calculations of offsets to figure which morph to select.
>
> The idea is to create a 2D matrix of morphs and because I know how wide
> and how high each morph is, I can calculate the  indices based on the
> number of squares that  the #fromUser rectangles will encompass , rather
> testing individual bounding rectangles themselves.
>
>
> So if I have a 10 x 10 matrix of morphs, each 10 x 10, then if my
> rectangle hits the morph at row1, col1, and is 80 pixels wide and high,
> then I know that morphs selected by a rectangle of indices atRow: 1atCol: 1
> through atRow: 8 atCol: 8 (moving down and to the right like pixels do)
> should all be selected.
>
> Each column and row having arbitrary  height/width   are much trickier,
> but I don’t have to handle that for this particular case.
>
> Realtime unselecting while mousedown is still true is going to be a little
> tricky, but the same calculations will work for those as well.
>
>
> That’s the plan currently, at least.
>
>
> L
>
>
> On Nov 29, 2022, at 11:05, karl ramberg <karlramberg at gmail.com> wrote:
>
> Here is a quite old spreadsheet like program. (2004)
> http://languagegame.org:8080/ggame/11
>
> Maybe you get some inspiration from that :-D
>
> Best,
> Karl
>
> On Tue, Nov 29, 2022 at 8:09 AM LawsonEnglish <LEnglish5 at cox.net> wrote:
>
>> I think you’re right. Im trying to see if a selection rectangle for cells
>> in a spreadsheet-like thing is selecting anything, so FIRST I do r1
>> intersects: rectangleList
>>
>> and then I guess iterate through again with #intersects: or perhaps I can
>> combine.
>>
>> I’m guessing I need to go look at some python spreadsheet code or
>> something.
>>
>> I’m working on the interface for the MorphleLogic simulator/programming
>> app for the first gen SiliconSqueak chip due out first half of next year.
>> It will allow one to manually (or programmatically) program an array of ML
>> cells as they they were simple logical elements, which allows optimization
>> of simple aspects of a software algorithm to be implemented in
>> reprogrammable hardware, so this will give folks a feel for what the chip
>> can do and hopefully inspire people to buy bunches of them for applications
>> as yet unknown. Projected cost of the chip will be in the $0.03 - $0.15
>> range in bulk, depending on how cheap they can design it to be. It’s an SOC
>> with circuitry designed for control of battery charging builtin, with an
>> eye to extending the life of EV battery packs by disabling charging of
>> individual batteries so you don’t have to recycle the entire pack to still
>> safely  recharge the rest of the pack. Secondary usecase is to keep track
>> of solar cell viability in a solar panel, to extend solar panel life.
>>
>> The SiSq CPU won’t have enough memory to hold the Squeak IDE so you’ll
>> need to program it from a laptop-based squeak (or perhaps a
>> smartphone-based Squeak), but it should be the first commercial chip
>> running the Smalltalk VM as the native ISA (it can also be switched to use
>> almost any other stack-based interpreter if you want to use it as a
>> SiliconPython chip or SiliconLua chip or whatever). The MorphleLogic part
>> simply allows one to optimize special bits of code in hardware, so I’m
>> working on the simulator/programmer for that part (the Squeak IDE is
>> already done, afterall).
>>
>>
>> L
>>
>> On Nov 28, 2022, at 22:50, karl ramberg <karlramberg at gmail.com> wrote:
>>
>> Hi,
>> I think you must use this method with a very similar name
>>
>> intersects: aRectangle
>> "Answer whether aRectangle intersects the receiver anywhere."
>> "Optimized; old code answered:
>> (origin max: aRectangle origin) < (corner min: aRectangle corner)"
>>
>> Best,
>> Karl
>>
>> On Tue, Nov 29, 2022 at 1:50 AM LawsonEnglish <LEnglish5 at cox.net> wrote:
>>
>>> I did this and created 2 small rectangles quite far from each other
>>> trying to figure out what the method returns when there is no intersection:
>>>
>>> r1 := Rectangle fromUser.
>>> r2 := Rectangle fromUser.
>>>
>>> r2 3072 at 993 corner: 3203 at 1136
>>> r1 2710 at 632 corner: 2835 at 752
>>>
>>> r2 intersect: r1 3072 at 993 corner: 2835 at 752
>>>
>>> r1 intersect: r2  3072 at 993 corner: 2835 at 752
>>>
>>> Could someone explain these results?
>>>
>>> Not in terms of the math involved (I assume that there’s no math bug as
>>> the routine was last edited 22 years ago and it is used everywhere in
>>> Morphic), but what the LOGIC is for returning what is returned and what it
>>> means in the context of the comments:
>>>
>>> intersect: aRectangle
>>>         "Answer a Rectangle that is the area in which the receiver
>>> overlaps with
>>>         aRectangle…. “
>>>
>>> I was trying to figure out how to look to identify when there is no
>>> intersection, and that isn’t at all obvious here.
>>>
>>> Thanks.
>>>
>>>
>>> L
>>>
>>>
>>
>>
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221202/c8bb53c8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SubSelect.st
Type: application/octet-stream
Size: 1955 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221202/c8bb53c8/attachment.obj>


More information about the Squeak-dev mailing list