## Rasterizing rotated ellipses

### Rasterizing rotated ellipses

I have a problem (don't we all?),

I need to draw rotated ellipses on the screen. Or to be more exact I need
to know what pixels rotated ellipses cover, hence I need to inspect every
pixel of every scanline which the ellipse occupies.

Currently I have a routine which rasterizes/scan-edges ellipses into a
start&end table indexed by scanline. However I need to handle rotation as
well. If I calculate my x,y as per usual and then rotate to give X,Y then
a fractional Y will cause (and has done) problems when I index the
scantable Y.

Does anyone know of any algorithm to perform this correctly??

Chris Killpack

### Rasterizing rotated ellipses

> I have a problem (don't we all?),

> I need to draw rotated ellipses on the screen. Or to be more exact I need
> to know what pixels rotated ellipses cover, hence I need to inspect every
> pixel of every scanline which the ellipse occupies.

> Currently I have a routine which rasterizes/scan-edges ellipses into a
> start&end table indexed by scanline. However I need to handle rotation as
> well. If I calculate my x,y as per usual and then rotate to give X,Y then
> a fractional Y will cause (and has done) problems when I index the
> scantable Y.

> Does anyone know of any algorithm to perform this correctly??

> Chris Killpack

Hi, Chris!
I have done this using general conics, i.e.

f(x, y) = ax^2 + bxy + cy^2 + dx + ey + f = 0

To calculate the coefficients for a given ellipse, you have to select two
point
on the curve and solve for the coefficients. In order to
generate the outline of the ellipse I'm using the midpoint forward
differencing
conic plotter described (brifly) in the bible; "Computer Graphic principles
and
practice". The basic idea is to divide the conic into eight octants according

to the gradiant (df/dx, df/dy) and then use the ordinary midpoint algorithm
to
decide between the two pixel choices for the given octant. Well read the
bible and try it.. It's a bit work, but you will not regret it... promise!

- Lasse S. Jensen

PS! If you get stucked mail me, and I send you a more detailed description.

### Rasterizing rotated ellipses

Quote:

>I have a problem (don't we all?),

>I need to draw rotated ellipses on the screen. Or to be more exact I need
>to know what pixels rotated ellipses cover, hence I need to inspect every
>pixel of every scanline which the ellipse occupies.

>Currently I have a routine which rasterizes/scan-edges ellipses into a
>start&end table indexed by scanline. However I need to handle rotation as
>well. If I calculate my x,y as per usual and then rotate to give X,Y then
>a fractional Y will cause (and has done) problems when I index the
>scantable Y.

A rotated ellipse looks the same on the screen as a skewed ellipse (albeit of a
slightly different eccentricity).  If you can generate the tables for the
upright case, then you can just skew that to get the tables you want.

Unfortunately, I did this 13 years ago and probably threw the actual code out
several house-cleanings ago.  However, getting the eccentricity and skew right
is not *too* bad.  (For the eccentricity, look at where the ellipse crosses the
x-axis; for the skew, look at where the points on the perimeter with maximum
and minimum y-values end up)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ian Kemmish                   18 Durham Close, Biggleswade, Beds SG18 8HZ, UK

Information on Jaws and 5D's other products availabe at http://www.five-d.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'The universe may be as great as they say,
but it wouldn't be missed if it didn't exist'  ... Piet Hein

Does anyone know where I might findcode to
create a rasterized tilted ellipse ?  I'm looking for
something along the lines of a Bresenham's line/cirle
algorithm. Ellipse algorithms are easy to find but I
can't seem to find one for a _tilted_ ellipse.
Help !
Thanx,
Chris