My question is how and what math do i use to manipulate the ellipse equation to form a midpoint algorithm and attempt to make a an ellipse. I get the code but don't understand the math that forms the basis of drawing an ellipse on screen. I'm wondering can some with experience tell me the math steps such as subtract from both sides something along those lines. I don't want the polynomial method that solves for the y and draws the first half then another pass to draw the second half. I understand that much of that method looking for the math involved for manipulating the equation.More along the lines looking for the math steps that manipulate the equation that i can then use to form the algorithm.
Asked
Active
Viewed 465 times
-1
-
I'm voting to close this question as off-topic because, as OP states *I get the code but don't understand the math* and this is a mathematical question, not a programming question. – High Performance Mark Dec 02 '15 at 22:14
1 Answers
0
I see ellipse midpoint like this:
The dx,dy
are absolute changes not relative ones !!!
So handle red and blue curves separately. The red part has |slope|<=1
which means that for each x
axis single increment/decrement change is up to one y axis increment/decrement change.
So for red curve:
I would use implicit equation so point inside ellipse is if (x/a)^2 + (y/b)^2<=1
. if you port this to integer by multiplying by (a*a*b*b)
you will get the term I use below this...
- set start point to
(0,b)
do a for loop where on each pass
- point (x,y) is rendered and all its mirrors
x
is incremented on each passy
is decremented only if(b*b*x*x+a*a*y*y>a*a*b*b)
which means your new(x,y)
point is outside ellipse.- if after the
y
change is still(b*b*x*x+a*a*y*y>a*a*b*b)
stop because you reached the midpoint (green line).
The blue curve
is almost identical you just start from (a,0)
and always increment y
axis instead of x
...
If you optimize the terms for incremental changes instead full recomputing (multiplying) per x,y
change you will get Bresenham ellipse algorithm.

Spektre
- 49,595
- 11
- 110
- 380
-
@deathreverse there is only one step ... and that is `((x/a)^2 + (y/b)^2<=1) * (a*a*b*b)` so you get `(b*b*x*x+a*a*y*y<=a*a*b*b)` this is computable on integers ... if it is true then point `(x,y)` is inside ellipse otherwise it is outside that is all – Spektre Dec 02 '15 at 22:13
-
could you explain the DERIVATION OF THE ELLIPSE GENERATING ALGORITHM – death reverse Dec 05 '15 at 05:51
-
@deathreverse what do you mean by that? you do not recognize the implicit ellipse equation `((x/a)^2 + (y/b)^2<=1)` or you are refer to partial derivations `dx,dy` which are not computed directly instead you test the inside ellipse twice ... no need to compute `dx,dy` if you code the steps I described in answer you will get ellipse rendered there is nothing more no more computing or equations .... – Spektre Dec 05 '15 at 08:31
-
@deathreverse as mentioned before you just need to multiply the implicit ellipse equation to get rid of the division so the sub-results will not be fractional hence computable on integers. – Spektre Dec 05 '15 at 08:34