4-connected midpoint ellipse algorithm

Started by
3 comments, last by Lantz 19 years, 11 months ago
I have this assignment where I'm supposed to write some 2D primitive generation code and I'm kinda stuck. I need to make a 4-connected (ie step x or step y only) ellipse using the midpoint algorithm. Everything I've found on the net does this, but 8-connected instead, so that doesn't help. The decision function for this is:

f(x,y) = x^2*b^2 + y^2*a^2 - a^2*b^2
Which gives the distance to a perfect ellipse with radius a in the x direction and b in the y direction. Using this as it is works perfectly, gives me a nice ellipse. But how do I take this and go to the incremental integer decision parameter form or whatever its called? I've tried messing around with it but I can't get it right, and the explanation in my book is crappy. Could anyone describe how to find the different values, ie. how to update the decision parameter and find its initial value etc? Thanks, Lantz [edited by - Lantz on May 21, 2004 6:05:47 PM]
Advertisement
4-connected? You mean an ellipse with 4 evenly distributed points?
Nope it means (according to my teacher) that one are only allowed to step in either x or y, no diagonal movement. Dont know if that makes sense.
rotate your matrix if you want diagional movement.

[edited by - cibressus on May 23, 2004 9:22:24 PM]
| Member of UBAAG (Unban aftermath Association of Gamedev)
Sounds like you looking for info on the Bresenham ellipse drawing algorithm. Use those keywords and google should pop up some nice results. That said, the question is off topic (homework) and so I''m closing the thread.

Graham Rhodes
Principal Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement