Topic 4.4 key terms
- parametrizing a line segment
- To move from to in seconds, start at the first point and add each coordinate's rate times : , , . The same segment has many parametrizations (faster, slower, backwards).
- linear interpolation (lerp)
- The point a fraction of the way from to : for . Game engines use it to move things between two points.
- unit circle parametrization
- for goes once around the unit circle, counterclockwise, starting and ending at . The domain decides how much of the circle is traced.
- parametric circle
- , traces the circle with center and radius ; the angle decides where it starts, which way it goes and how fast.
- lap time
- With and , one lap takes seconds (the period). Changing changes the time for a lap, not the circle.
- direction and starting angle
- With , the point starts at angle ; turns counterclockwise and turns clockwise. starts at the top and goes clockwise.
Transcript
2,488 words · 7 parts
Two formulas, one shot
This is a camera drone, a hundred and twenty meters above a lava field in Iceland, and in a few seconds it’s going to clear that ridge and show us something incredible. That’s a volcano erupting, throwing fountains of lava fifty meters into the air, with a river of it pouring away across the field.
Now watch what the drone does next. It swings into a perfect circle around the fire, with the camera locked on it while the whole landscape turns behind it. Camera drones have a special mode for this. You tap the thing you want to circle, and you choose how far away, how fast and which way. Then the drone flies the circle by itself.
But underneath that button, the whole shot is just two functions of time, one that says how far east of the pilot the drone is, and one that says how far north. By the end of this lesson, you’ll be able to write those two functions yourself, for a straight line from any spot to any other, and for a circle around anything, starting where you want, going the way you want, and taking exactly as many seconds as you choose.
And at the very end, you’ll plan the next shot of this eruption yourself. Then the drone will fly your math. Let’s begin with the straight part of the shot. It’s the easier half, and it only needs one idea. We’ll get to the circle after that.
The straight line
Here’s the straight part of the shot on the map, seen from directly above, with the pilot standing at zero, zero. The drone stays at one height the whole way, so every position is just meters east and meters north of the pilot. The drone starts at negative one hundred, one hundred, a hundred meters west of the pilot and a hundred north, and it flies straight to three hundred, three hundred in forty seconds.
Over the whole trip, the drone moves four hundred meters east and two hundred meters north. Let’s fly it again. This time, keep an eye on both of those changes. Watch them fill up as the drone goes.
Let’s stop the clock at ten seconds, a quarter of the way through. The drone has done a quarter of the east change, a hundred meters, and a quarter of the north change, fifty, so it’s at zero, one fifty. And that’s what keeps the drone on a straight line, because at every moment it has done exactly the same fraction of the east change as of the north change. Let’s flatten the map onto the board. Then we can work out the formulas.
Here’s a table of where the drone is every ten seconds. At zero seconds it’s at negative one hundred, one hundred, and ten seconds later it’s at zero, one fifty. Each time, x goes up by a hundred. And each time, y goes up by fifty.
Ten seconds was a quarter of the forty-second trip. After t seconds, the drone has done t over forty of it. So x starts at negative one hundred and adds t over forty of four hundred. That’s ten t.
It’s the same for y, so we start at one hundred and add t over forty of the two hundred meters north, which is five t. That ten and that five are rates, ten meters east every second and five north, and each one is that coordinate’s change divided by the time, four hundred over forty and two hundred over forty.
So a straight trip is an initial position plus a rate for x and a rate for y, each times t. Those are the rates of change of x and of y with respect to t. We also have to tell the formulas when to stop, because on their own they’d keep going forever, so the domain is part of the answer, zero to forty.
If we let the clock run to sixty seconds, the drone keeps going along the same line, all the way to five hundred, four hundred, right out over the lava. Game developers call this lerp, short for linear interpolation. They use a fraction from zero to one, from the start of the trip to the end.
Now fly the same trip in just twenty seconds. Set the drone’s two rates, then press fly and see where it lands. So now we have two different flights along exactly the same line. Here’s the forty-second one.
The twenty-second one goes twice as fast. It stops at t equals twenty. You can even fly it backwards, starting at three hundred, three hundred and subtracting the rates. The line on the map stays the same every time, and only the timing changes, which is why one segment has lots of different parametric functions. And because we never needed a slope, a trip due north works just as well, with x stuck at three hundred.
A drone has to fly from the point two hundred, negative one hundred, to the point negative one hundred, five hundred, in thirty seconds. Which plan does exactly that?
Once around
Now for the circle, and every circle the drone flies starts from one simple circle, the unit circle, radius one, centered at the origin, with the point cosine t, sine t. For now, t is an angle in radians. The cosine tells you how far across the point is, and the sine tells you how far up.
At zero the point is at one, zero, on the right. At pi over two it’s at the top, zero, one, at pi it’s on the left, at negative one, zero, at three pi over two it’s at the bottom, and at two pi it’s right back where it started. So as t runs from zero to two pi, the point goes exactly once around the circle, counterclockwise, starting and ending at one, zero.
On the drone’s map, counterclockwise means east first, then north, then west, then south, and back to east. And it really is a circle, because cosine squared plus sine squared is always one, so the point is always exactly one unit away from the center. Unroll the two coordinates against t. You get the cosine and sine graphs from the trig unit. Both run on the same clock.
But here’s a puzzle. The point starts and ends at the same spot, so how do we know it went anywhere? The middle tells us, because it passed the top, the left and the bottom.
That’s why the domain matters so much. From zero to pi you only get the top half, and from zero to four pi the point goes around twice. Suppose t runs from zero all the way to three pi. Where does the point end up?
Any circle you want
Let’s take that circle back to the volcano. Here it is on the map around the pilot, and with a radius of one meter, a drone flying it would take your eyebrows off. To make it bigger, we multiply both coordinates by the radius we want, say a hundred meters, so the point becomes a hundred cosine t, a hundred sine t.
That circles the pilot, but we want the vent, four hundred meters east and three hundred north, so we add four hundred to x and three hundred to y, and the circle slides onto the fire. Notice that x gets the cosine and y gets the sine. Give them both a cosine, and the drone just slides back and forth along a diagonal line.
There’s also a problem with time. If t is in seconds, the drone turns one radian every second and finishes a lap in about six seconds, at a hundred meters a second. To slow it down, we put a number b in front of t. It’s the same b that set the period of a sine wave. Then one lap takes two pi over b seconds.
For a forty-second lap, two pi over b has to be forty, so b is two pi over forty, which is pi over twenty. Watch the ring while the lap slows down. It doesn’t move at all, because the speed knob only changes how long a lap takes.
Here’s the whole build on the board. We started with cosine t, sine t, stretched both coordinates by the radius, and slid the center to four hundred, three hundred. Then we set the clock, with b equal to pi over twenty for a forty-second lap. Here are the two formulas that fly it.
One lap takes forty seconds, so the domain is zero to forty, and zero to eighty would go around twice. And any circle like this one is just its center plus its radius times the cosine and the sine of b t.
Now you set the clock. Pick the value of b that makes one lap of the vent take exactly sixty seconds, then press fly and watch the stopwatch.
Which way, and where it starts
So far, every circle we’ve written has started on the east side and gone around counterclockwise. To send the drone the other way, we keep the cosine and put a minus in front of the sine.
Just after t equals zero, the sine of b t is small and positive. The first drone starts moving north. The minus flips the second drone’s y, so it heads south. It goes around clockwise.
Through the drone’s camera, the landscape slides one way for the first shot. For the second shot, it slides the other way. From above, the two drones are mirror images. They always share an x, and one is as far south as the other is north.
Turning backward on the unit circle does that too. It keeps the cosine and flips the sine. So a minus on the sine means the drone turns backward. Its angle is minus b t.
You also get to choose where the drone starts. The angle inside the cosine and the sine doesn’t have to start at zero. We call its starting value phi. Start it at pi over two, and the drone starts due north of the vent.
At time t, the angle is phi plus the turning so far, b times t. That’s counterclockwise. For clockwise, the turning comes off instead. It’s the same minus we just saw. Start due north and go clockwise.
The angle starts at pi over two, and the turning comes off. That’s pi over two minus b t. Your turn. This drone starts due west of the vent and goes clockwise. Which angle does it use?
Now put that angle into the circle. x is h plus r times the cosine of theta. y is k plus r times the sine of theta. Here b is two pi over T, where T is the lap time.
A classic mix-up swaps them: sine t, cosine t. At t equals zero, that point sits at zero, one, the very top. A moment later x has grown, so the point has moved right. From the top, moving right is clockwise. The swap isn’t a typo, then.
It’s a real orbit. It starts at the top, and it turns clockwise. That’s the test for any plan. Put in t equals zero to find the start. Then see which way it moves next.
Here’s another plan for orbiting the vent. Where does the drone start, and which way does it go around? Now we can decode the orbit from the start of the lesson. It circles the vent at a hundred meters, starting due west of it. It goes clockwise, and it takes forty seconds a lap.
Due west is an angle of pi, clockwise means we subtract the turning, and a forty-second lap means pi over twenty, so the angle is pi minus pi t over twenty. That gives the two formulas for the whole orbit, x is four hundred plus a hundred times the cosine of that angle, and y is three hundred plus a hundred times its sine, for t from zero to forty. Let’s make sure it does what we asked. At t equals zero, the cosine of pi is negative one, so the drone is at three hundred, three hundred, exactly where the reveal ended.
At ten seconds the angle is pi over two. That puts the drone at four hundred, four hundred, due north of the vent. Going from west to north is clockwise. And that’s every number in the shot from the beginning of the lesson. We’ve decoded all of it.
Your shot
Up the fissure, there’s a second vent, at one hundred, five hundred. So here’s the plan for the next shot, and this one’s yours. First, a straight flight from where the first orbit ended, at three hundred, three hundred, to the south side of the second vent, at one hundred, four fifty, in twenty-five seconds. Then a circle around the second vent at fifty meters, starting due south, going clockwise, one lap every thirty seconds.
Let’s start with the straight part, from three hundred, three hundred to one hundred, four fifty in twenty-five seconds. What should the drone’s east rate be, in meters per second?
Now for the orbit. This time, you’re going to write the whole plan yourself. Fill in each part of the plan, and when you’re happy with it, press fly. The drone will fly exactly what you wrote.
So let’s watch your shot from the drone’s own camera. We’ll see the whole thing, from start to finish. There’s the orbit we decoded. It goes clockwise, starting from the west side of the cone. and now it’s your part, eight meters west and six meters north every second, and then your circle around the second vent.
Every second of what you’re watching comes from four pairs of formulas, two straight lines and two circles, and you know how to write every one of them. And from out here, you can see the whole flight plan. The drone wrote it in light, right across the sky. Here are all four pieces on the map. Each one has the formula that flies it.
Lines and circles
So here’s everything in one place. A straight line in T seconds starts at the first point and adds each change divided by T, times t, until t reaches T. Cosine t, sine t goes once around the unit circle, counterclockwise from one, zero, as t runs from zero to two pi, and every other circle is that one, stretched, slid, and given its own start, direction and lap time.
And if the sine and the cosine are swapped, the drone starts at the top. Then it goes clockwise. Game engines call that straight line lerp, and in calculus you’ll work out how fast the drone really moves along its path. So next time you see a drone shot circling something, you’ll know there are two little functions of time flying it.
