Lesson goal: For loops and rotating math functions for plotting

Previous: Coaxing Pi from the computer | Home | Next: Find sin(x) by adding numbers

In a previous lesson you plotted a parabola. Plotting something like $y=x^2$ might seem pretty easy. But what if you wanted to draw a parabola that was rotated by say $15^\circ$? How would you do that?

It turns out that if you want to rotate an $(x,y)$ point through an angle of $\theta$, you can use these equations to compute a new $(x,y)$ pair, that is rotated through and angle $\theta$:

$xp = x \cos\theta - y \sin\theta$
$yp = x \sin\theta + y \cos\theta$

In this notation, if $x$ and $y$ are your unrotated (or "normal") points, then $xp$ and $yp$ will be where the point would be, if rotated through $\theta$ degrees.

Now you try. Program in the rotation formulas above and see if you can draw a parabola rotated through $15^\circ$.

Type your code here:

See your results here: