[vwnc] Rectangle

View: New views
6 Messages — Rating Filter:   Alert me  

[vwnc] Rectangle

by bqueyras :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it normal  that a rectangle with an origin left to its corner does
not contain a point like this:

(  (0@0) corner: (-1@-1) ) containsPoint: (-0.5@...) -> false

Bernadette Queyras

_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Re: [vwnc] Rectangle

by Cesar Rabak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

bernadette Queyras escreveu:
> Is it normal  that a rectangle with an origin left to its corner does
> not contain a point like this:
>
> (  (0@0) corner: (-1@-1) ) containsPoint: (-0.5@...) -> false
>
Bernadette,

Inspect the rectangle you created and look at the method
Rectangle>>containsPoint: aPoint
        "Answer whether the argument aPoint is within the receiver."

        ^origin <= aPoint and: [aPoint < corner]

Notice that the logic checks if aPoint is greater than origin, but

(0@0) <= (-0.5@...) "false"

also

(-0.5@...) < (-1@-1)  "false"

If this "normal" (which I believe you meant "acceptable") is a thing to
check within the context of your application.

HTH

--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/
_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Re: [vwnc] Rectangle

by Andres Fortier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe the thread 'Rectangle #contains: and #containsPoint' (25/04/07)
will answer your question.

HTH,
         Andrés


bernadette Queyras escribió:

> Is it normal  that a rectangle with an origin left to its corner does
> not contain a point like this:
>
> (  (0@0) corner: (-1@-1) ) containsPoint: (-0.5@...) -> false
>
> Bernadette Queyras
>
> _______________________________________________
> vwnc mailing list
> vwnc@...
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Re: [vwnc] Rectangle

by jtuchel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, yes, I guess so. At least I get the same result in VA Smalltalk.
Looking at the implementiation it is at least explicable:

containsPoint: operand

    "Answer true if the receiver contains the point operand.  Otherwise
     answer false."

    ^operand >= origin and: [operand < corner]

Good luck

Joachim

bernadette Queyras <bernadette.queyras@...> hat am 6. November 2009 um
16:05 geschrieben:

> Is it normal  that a rectangle with an origin left to its corner does
> not contain a point like this:
>
> (  (0@0) corner: (-1@-1) ) containsPoint: (-0.5@...) -> false
>
> Bernadette Queyras
>
> _______________________________________________
> vwnc mailing list
> vwnc@...
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


--
-------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:jtuchel@...
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1

_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Re: [vwnc] Rectangle

by Henrik Johansen-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes.
If you're not sure when creating the rectangle which points x/y is  
topLeft, you should use the vertex:vertex: constructor.

Cheers,
Henry

On Nov 6, 2009, at 4:05 56PM, bernadette Queyras wrote:

> Is it normal  that a rectangle with an origin left to its corner does
> not contain a point like this:
>
> (  (0@0) corner: (-1@-1) ) containsPoint: (-0.5@...) -> false
>
> Bernadette Queyras
>
> _______________________________________________
> vwnc mailing list
> vwnc@...
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Re: [vwnc] Rectangle

by Andre Schnoor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Is it normal  that a rectangle with an origin left to its corner does
> not contain a point like this:
>
> (  (0@0) corner: (-1@-1) ) containsPoint: (-0.5@...) -> false

Use the #vertex:vertex: message to create rectangles from arbitrary  
points. That sorts the points appropriately, i.e. in your case you get  
a rectangle (-1@-1) corner: 0@0.

Andre


_______________________________________________
vwnc mailing list
vwnc@...
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc