General ellipse algorithm

Started by
1 comment, last by JoelP 21 years, 6 months ago
I''m looking for a general ellipse algorithm. One that can draw an ellipse at any orientation. The few I''ve come across on the internet are nearly impossible to understand and to convert to programming code, plus they don''t work. I have an algorithm for drawing an ellipse alligned to the XY axis but using Trig to rotate it results in a jagged ellipse with some gaps. Joel
Computers are fun.
Advertisement
Ok - I found some code for converting an elipse to bezier curves hidden in this article

http://codeguru.earthweb.com/gdi/dashed.shtml

which may help - if not then you could use a polygon with a large number of sides and distort/transform the points(depending upon your accuracy requirements and code speed constraints).

I have found that in many apps the latter is acceptable for display purposes if the number of sides is large enough as the starting points can be precalculated from a unit circle and then distorted/transformed to fit.

Hope this helps

Box2020<CEng&,CRnd*>
I think this is somewhat the same as Box2020 said

Use XY-aligned ellipse
for (double angle = 0; angle < 2*pi; angle += STEP) {
x = cos(angle) * a + centerX
y = sin(angle) * b + centerY
}
rotate it with some extra trigonometry stuff and connect adjacent points with lines. The results should be satisfactory and fast.

This topic is closed to new replies.

Advertisement