You can draw an ellipse by drawing a circle tilted towards or away from the viewer.
Draw an ellipse in the x,y plane (z = 0).
Create and interactive program to draw an ellipse in the x,y plane (z = 0). Ask the user to input:
1. Because we are drawing individual pixels, round x,y coordinates to integer values.
2. You only need to calculate 1/4 if the points on the surface of the ellipse. The ellipse is symmetrical around the x and y axes when drawn in the xy plane (z = 0).
+y | (-x,y) | (x,y) | -x --------+-------- +x | (-x,-y) | (x,-y) | -y
3. Pseudo code - draw an ellipse
Note: This code tilts the circle around the X axis.
win = create_a_drawing_window() for x in [0,1,2,3,4, ..., r]: y = calculate_ellipse_y_coord(x,r,θ) draw_a_point(win,x,y) draw_a_point(win,x,-y) draw_a_point(win,-x,y) draw_a_point(win,-x,-y)
4. The X coordinate should never be larger that R.
Use graphics.py to draw the ellipse. Click HERE for more information. (download, install, documentation, ...)
Equation From: Calculating angle of circle to produce given ellipse