Stephen Johnson of Sun Microsystems, California asks:
$ Maybe someone has a better technique for generating that skewed
$ ellipse at the quickest speed possible.
Here are two related methods. The first method is best if the maximum
speed at given (imperfect) accuracy is required. It is faster than
the second method which gives the maximum speed at perfect accuracy.
By the way, I can't think of any algorithm that works more than twenty
per cent faster for non-tilted ellipses than tilted ones.
Lets suppose that the tilted ellipse is specified by the
major axis, minor axis, x at centre, y at centre and slope.
Call these values MAJOR, MINOR, Xcentre, Ycentre, SLOPE.
The tilted ellipse has points with coordinates:
a = .5 * MAJOR * cos(SLOPE)
b = -.5 * MINOR * sin(SLOPE)
c = .5 * MAJOR * sin(SLOPE)
d = .5 * MINOR * cos(SLOPE)
A = sqrt(a*a+b*b)
B = sqrt(c*c+d*d)
ANGLE = arcsin(c/B)-arcsin(a/A)
The values A, B and ANGLE are calculated once for each ellipse.
Find Xcentre, Ycentre, A, B, and ANGLE once for each ellipse.
Join new values of X and Y to old values of X and Y with a straight line.
of the resulting ellipse.
Find Xcentre, Ycentre, 1/A, B, and ANGLE once for each ellipse.
Increment X and find Y from
Join new value of Y to old value of Y with a vertical line.
Here X is incremented one pixel at a time. Don't forget that
arcsin has two values; one for the top half of the ellipse and
one for the bottom half.
CSIRO Division of B,C & E,
PO Box 56 Highett, Victoria. 3190.