This page contains large animations.
Download the Maple Worksheet
Back to first example
Back to the Maple Tutorial Table of Contents
Let's walk through another example of animations. The goal is to create a circle representing the unit circle, and have a line go from (0,0) to the corresponding point on the unit circle for theta, theta=0..2Pi
First, let's create our unit circle. We will use plottools[circle]() to draw the circle. plottools[circle]() expects two arguments. The first is a vector containing the X,Y coordinates for the center. The second is the radius of the circle. You can also include plot options.
> c:=circle([0,0],1): #As you may know, the unit circle has a radius of 1 and a center of (0,0).
Now that our circle is created, let's work on the moving line. The plottools[line]() command is rather simple. It takes two arguments. Both arguments are vectors specifying the start and end points for the line. As with most drawing commands, you can use plot options. To illustrate, let's draw a line from (0,1) to (1,0).
Now that we can draw a line, let's worry about how to position the endpoint. As you may remember, the endpoint for the line we want is (cos(theta),sin(theta)) where theta is the measure of the angle from (1,0). Let's practice by drawing a line for theta=Pi/4.
This is the line we want! Now, let's do the animation!
> display(seq(line([0, 0], [cos(t/100), sin(t/100)]), t=0..200*evalf(Pi, 3)), insequence=true);
I'm sure you'd like an explanation, so here goes. To make things easier, let's examine the above statement piece by piece. The first piece I'd like to examine is t=0..200*evalf(Pi,3)). Our original goal was to go from 0..2Pi since that is the dimension of the unit circle. However, seq() does not like floating-point numbers. Therefore we must convert all numbers to integers. The evalf() statement evaluates Pi at 3 Digits (Yes I know, it's 3.14; I wanted to make a point). Then, we need to move the decimal point right two spaces. We do that by multiplying Pi by 100. Finally, we want 2Pi, so we multiply that by two.
To keep the equilibrium thing going in our problem, we need to modify t. Since we multiplied it by 100, we must divide every occurrence of t by 100 to keep our original dimension.
That was the hardest part of the problem and this is probably one of the most complicated animations you will have to do.
Now, let's store our animation in a variable for safekeeping.
> l:=display(seq(line([0, 0], [cos(t/100), sin(t/100)], color=red), t=0..200*evalf(Pi, 3)), insequence=true):
> display(c, l, scaling=constrained); #and display it with constrained scaling so the circle doesn't look like an ellipsis