On Jun 18, 2012, at 11:25 AM, Joaquin Zabalo wrote:
> I’m using OvalPortrayal2D(6) to display large disks and OvalPortrayal2D() to
> display small disks and I need to know when the small disk overlaps the
> large disk.
OvalPortrayal2D draws disks centered at the desired coordinate. Note that what a "coordinate" is varies from field to field. For continuous fields, the coordinate is exactly what you expect. For grids, the coordinate is offset by 0.5 in each direction (in model space) so circles will fill squares and not lie on intersections of the grids. See the MASON Manual for more information on that.
> My question is, what is the radius of the large disk OvalPortrayal2D(6)?
> Does scale 6 denote the number of units across and hence the diameter of the
> disk?
The width [and correspondingly height] of the portrayed disk is defined as 1.0 * W * S + O, where W is the scaling factor of the underlying field, S is the "scale" value of the OvalPortrayal2D (in your example, it's the "6"), and O is an additional offset in pixels. The W changes as the user zooms in and out, that's handled automatically for you.
However you need to realize that OvalPortrayal2D is NOT intended to be used to describe the actual width of the model objects. You really ought to handle that in your model proper, and use OvalPortrayal2D to just make the picture pretty.
Assuming you're in a continuous world, the easy way to tell if two disks (in the *model*) have overlapped is this. Let's say that your underlying model objects have X and Y locations and radii R. Disk A overlaps with disk B if (A.X  B.X) * (A.X  B. X) + (A.Y  B.Y) * (A.Y  B.Y) <= (A.R + B.R) * (A.R + B.R), right?
Sean
