Matthew Moss
6/14/2008 9:34:00 PM
> > > For example:
>
> > > =A0 =A0 ruby circle.rb 7
>
> > > Should produce a circle of radius 7
>
> > I'm not sure if this is intentional but the circle is 15 characters
> > high. Of course, the line has to be counted in too.
> > Nevertheless ... :-)
>
> > Regards,
> > Thomas.
>
> Depends on where you are measuring the radius:
>
> outside: 7.5
> inside: 6.5 (white space is 13 characters high)
> center: 7 (center of bottom to center of top is 14)
It was quite intentional that my circle of radius 7 took up 15 rows of
characters. This is a common issue when dealing with computer
graphics: how do you measure distance on a field of discrete elements?
In computer graphics, this is often not a big deal when drawing 3d
objects, especially if you have blurring, other post-processing, or
anti-aliasing going on. It is much more important when you are trying
to render a HUD or UI elements, for example, that you want pixel-
perfect to the artwork provided. Many graphics cards have a setting
you can enable/disable to offset coordinates by half a pixel...
Putting it into the correct mode and setting your texturing unit to
point sampling mode (as opposed to tri-/bi-linear sampling) will give
you pixel-perfect results.
So, in the case as I presented it, I was measuring from the center of
the character cell, which is 15 rows high *if measured from the top
edge of the top row to the bottom edge of the bottom row*. But as Eric
pointed out, it's only 14 if you measure from character cell center's.