#### Archived

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

# General ellipse algorithm

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

## 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 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 on other sites
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.

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
17
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632577
• Total Posts
3007157

×