Combine Vogel’s Model with Mosaic Projects to draw a mosaic Vogel’s model with Python Turtle.
Tag Archives: parametric curve
Mosaic Butterfly Curve with Python Turtle
This project is combination of butterfly curve and mosaic project. Figure out how to combine the two to draw a mosaic Butterfly Curve.
Mosaic Lissajous Curve with Python Turtle
This project is combination of Lissajous Curve Project and mosaic project. Figure out how to combine the two to draw a mosaic Lissajous Curve.
Mosaic Heart Curve with Python Turtle
This project is combination of heart curve project and mosaic project. Figure out how to combine the two to draw a mosaic heart curve.
Animation of Ellipses with Parametric Equations
You drew an ellipse with parametric equation. Animate the drawing process with different values of a and b.
Animating Lissajous Curve with Python Turtle
We drew a Lissajous Curve with fixed value for k1 (3) and k2 (2). Lets gradually change k1 from 0 to 3 and draw each one of them to generate an animation sequence as shown in this video:
Drawing General Ellipse with Python Turtle
We drew an ellipse centered at origin without tilt. In this project, we will draw a general ellipse that can be centered at any location and any tilt angle. The parametric equation for this general ellipse is as follows:
x = cx + a*math.cos(t)*math.cos(math.radians(angle))-b*math.sin(t)*math.sin(math.radians(angle))
y = cy + a*math.cos(t)*math.sin(math.radians(angle))+b*math.sin(t)*math.cos(math.radians(angle))
(cx, cy) is the coordinate of the center of the ellipse. angle is the tilt angle of the ellipse. Range parameter t from 0 to 2π gradually to draw general ellipses.
Solution:
import turtle
import math
screen = turtle.Screen()
screen.setup(1000,1000)
screen.title("General Ellipse with Parametric Equation - PythonTurtle.Academy")
screen.tracer(0,0)
turtle.speed(0)
turtle.hideturtle()
turtle.up()
n = 2000
# (cx,cy): center of ellipse, a: width, b:height, angle: tilt
def ellipse(cx,cy,a,b,angle):
# draw the first point with pen up
t = 0
x = cx + a*math.cos(t)*math.cos(math.radians(angle))-b*math.sin(t)*math.sin(math.radians(angle))
y = cy + a*math.cos(t)*math.sin(math.radians(angle))+b*math.sin(t)*math.cos(math.radians(angle))
turtle.up()
turtle.goto(x,y)
turtle.down()
turtle.color('red')
# draw the rest with pen down
for i in range(n):
x = cx + a*math.cos(t)*math.cos(math.radians(angle))-b*math.sin(t)*math.sin(math.radians(angle))
y = cy + a*math.cos(t)*math.sin(math.radians(angle))+b*math.sin(t)*math.cos(math.radians(angle))
turtle.goto(x,y)
t += 2*math.pi/n
ellipse(-200,-100,200,100,45)
ellipse(200,100,40,200,80)
turtle.update()
Drawing Ellipse with Parametric Equation in Python Turtle
We have several projects drawing ovals. Ellipse is not the same oval. An ellipse is a curve surrounding two focal points such that the sum of the distances to the two focal points is constant for every point on the curve. Ellipse is a generalization of a circle (where two focal points at the same location). The parametric equations for an ellipse is as follows:
x = a*math.cos(t)
y = b*math.sin(t)
The equations are very similar to those of circle except that instead of one single radius, we have two: a, b. Use the equations to draw the following ellipse:
Drawing Circle with Parametric Equation
Although there is built in function to draw a circle in Turtle, let’s draw circles in a different way with parametric equation. The parametric equations for a circle is very simple:
x = radius*math.cos(t)
y = radius*math.sin(t)
In the equations above t is the parameter, x, y are the coordinates of the points on the circle. Let t start from 0 and go up to 2π gradually.
Lissajous Curve with Python Turtle
Lissajous Curve is a famous curve with both practical use and in art and design. It is generated by a simple parametric equation:
x = 300*math.cos(k1*t)
y = 300*math.sin(k2*t)
In the equation above t is the parameter. Let it range gradually from 0 to 4π. Set k1 to 3 and k2 to 2 and drawing the following shape. You can play with other numbers for k1 and k2 to see different curves.