Final Result Preview
Let’s take a look at the final result we will be working towards. Use the left and right arrow keys to steer the ship (triangle), and press up to boost the speed temporarily. If the projected future collision point is on the wall (the line), a red dot will be painted on it. For a collision that “already” happened (i.e. would have happened in the past, based on the current direction), a red dot will still be painted but slightly transparent.You can also mouse click and drag the black dots to move the wall. Note that we don’t just predict the location of the collision, but also the time.
Step 1: Revision
Before getting into the topic, let’s do some revision. Here’s the dot product equation (previously covered here):

Step 2: Perpendicular Dot Product
Now to help us form a mental picture, I’ve prepared the image below. I’m confident at this point you are able to derive the vertical and horizontal components of a vector, so the components involving sine and cosine shouldn’t be a challenge.

|B|*cos (theta)
. But why would the projection of B’s normal produce |B|*sin (theta)
? [...]Read more: Predicting Collision Points With Math in AS3
No comments:
Post a Comment