How a 'Contains' method returns true?

Hey there,

Just looking for help from a second eye on this bug. Basically, I am still in the process of writing my intersects method and I have gotten somewhere since I got sent the project with the ‘Segment’ and ‘Point’ classes. So thank you very much to whoever that person was that helped. I cannot seem to track this person’s name down but this person was very helpful.

I seem to have gotten the line intersection part of the method to work. This is basically where in my method, I need to detect whether any of the points in one rectangle are contained within another. For some reason, the contains method returns true when it is not suppose to.

So for debugging I tried this code:

    if item1.Contains(5, 5) then
      msgbox str(item1.X)
end if

The strange thing (in my opinion) with this, is that the msgbox shows a number that is considerably higher than 5. The shape has no rotation AFAIK. If item1 is not even positioned at 5, 5 or lower values then how could this possibly return true?

I might have gotten it wrong.


Is .Contains(x,y) based on item1’s top left, rather than the window’s top left?

I would imagine it should be based off of item1’s top left. I would also imagine the window has nothing to do with this code. What I am trying to get my head around is why item1 ‘contains’ the point 5, 5 while the position of item1 is more than item1’s coordinates.


Maybe post the code where you create item1? It would seem likely that you aren’t positioning it where you think you are.

This code returned true. But look at the properties of the class.


The point 5,5 IS contained in the rectangle. X, Y in an object2d is NOT the top/left. It is the center of the object.

Thanks for your input. I will have a look at where I went wrong with positioning the Object2D.