Re: Code quality
Logan Shaw said:
[color=blue]
> It could be quite useful to make one set of limits inclusive and the other
> exclusive. Left and top could be inclusive and right and bottom
> exclusive. This has the nice property that if region1 and region2 are
> exactly adjacent to each other horizontally (and region1 is the one to the
> left), then
> region1.right == region2.left. If everything is defined as inclusive,
> then testing whether things abut each other exactly gets uglier.[/color]
A slightly more intuitive way to capture that feature is to record width and
height rather than right and bottom, so that you'd have something like:
if(s1->left + s1->width == s2->left)
{
if(s1->top + s1->height >= s2->top &&
s2->top + s2->height >= s1->top)
{
/* s2 abuts, and is right of, s2, modulo bugs */
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
email: rjh at above domain (but drop the www, obviously)
Logan Shaw said:
[color=blue]
> It could be quite useful to make one set of limits inclusive and the other
> exclusive. Left and top could be inclusive and right and bottom
> exclusive. This has the nice property that if region1 and region2 are
> exactly adjacent to each other horizontally (and region1 is the one to the
> left), then
> region1.right == region2.left. If everything is defined as inclusive,
> then testing whether things abut each other exactly gets uglier.[/color]
A slightly more intuitive way to capture that feature is to record width and
height rather than right and bottom, so that you'd have something like:
if(s1->left + s1->width == s2->left)
{
if(s1->top + s1->height >= s2->top &&
s2->top + s2->height >= s1->top)
{
/* s2 abuts, and is right of, s2, modulo bugs */
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
email: rjh at above domain (but drop the www, obviously)
Comment