Archived

This topic is now archived and is closed to further replies.

General ellipse algorithm

This topic is 5536 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites