|
|
||
|
|
||
|
|
||
Heres a reminder of the two main formulas introduced in this chapter.
Coordinate rotation:
x1 = Math.cos(angle) * x
Math.sin(angle) * y;
y1 = Math.cos(angle) * y
+
Math.sin(angle) * x;
Reverse coordinate rotation:
x1 = Math.cos(angle) * x
+
Math.sin(angle) * y;
y1 = Math.cos(angle) * y
Math.sin(angle) * x;
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
As youve seen in this chapter, coordinate rotation can give you some very complex behavior, but it all boils down to a couple of formulas that never change. Once youre comfortable with the formulas, you can use them
Youll be using the coordinate rotation formula quite a bit in the
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
What well cover in this chapter:
Mass
Momentum
Conservation of momentum
Important formulas in this chapter
As you might expect in a technical book like this, things start off simple and gradually become more complex. With this chapter, you reach a pinnacle of complexity. Not that the rest of the chapters after this are all downhill, but I think this one in particular requires that you have not skimped on the material that came earlier. That said, Ill walk you through the concepts step by step, and if youve followed along reasonably well up to now, you should be fine.
Specifically, this chapter will focus on momentum: What happens to the momentum of two objects that collide, the conservation of momentum, and how to apply this conservation of momentum in ActionScript to movie clips.
As the objects used in these examples are all round, for simplicitys sake, this subject is often referred to as billiard ball physics. And youll soon see that these examples really do look like a bunch of different-
As in previous chapters, when I get to the code, Ill start you out on one dimension to keep things simpler and easier to understand. Then Ill move into two dimensions, at which point youll need to jump into some coordinate rotation (the subject of the previous chapter). Essentially, youll be rotating the two-dimensional scene so it lies flat. You can then ignore one axis and treat it as a one-dimensional scene. But all that is just to whet your appetite for whats coming up. Lets start with the simple concepts of mass and momentum.
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
The earlier chapters of the book have gone into several aspects of motion: velocity, acceleration, vectors, friction, bouncing, easing, springing, and gravity. One thing that I have pretty successfully gotten away with ignoring is the concept of the mass of the object being moved around. Now, Im going to
Unfortunately, or maybe fortunately, I have reached a point where I just cant ignore mass any longer. Mass is just so tied up in the subject of momentum that Im just going to have to confront it head on.
So just what is mass? Here on earth, we usually think of mass as how much something weighs. And thats pretty close, as weight is proportional to mass. The more mass something has, the more it weighs. In fact, we use the same terms to measure mass and velocity: kilograms,
This also
|
|
||
|
|
||
|
|
||