'Ellipse drawing

I'm trying to draw an ellipse using only glVertex2i function, I'm letting the user to enter 2 foci points and a point on the ellipse. My question is: how to find the rest of the ellipse points.



Solution 1:[1]

Have a look here. The steps you have to do are:

  1. Transform your coordinate system such that the too foci points lie at (-c,0) and (+c,0)
  2. Compute the semimajor axis as 2*a = r1 + r2 where r1 resp. r2 are the distances between the given point and the foci points.
  3. Compute the semiminor axis as b*b = a*a - c*c
  4. Now you can use the simple parametric form x = a*cos(t) and y = b*sin(t) with t ranging from 0 to 2 pi to create sample points on the ellipse.
  5. Transform these points back using the inverse of the transformation from step 1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Danvil