Hi all,

Well I'm done responding to list craziness and since you get what you focus on, 
I'm focusing on cool game mechanics! :)

I'd like to take my earlier notes on vectors and such, a step further to a 
process called projection.

When you project a vector on to another vector, you're simply adding the 
components of one vector to the components of another. As in:

0,2,0 + 1,0,0 = 1,2,0

So this process is just adding the x, y, and z components of each vector 
separately as in:

0 + 1 = 1

2 + 0 = 2

0 + 0 = 0

So this is great but why would we want to do this?

Let's think of the first vector above (0,2,0) as perhaps a boat on an ocean. 
This boat is traveling north in our game world, at 2 units per some amount of 
time.

Let's think of the second vector as a wind blowing toward the east at 1 unit 
per some amount of time. You can see where I'm going with this. ;)

If we apply the wind to the boat's motion, we end up with the boat traveling to 
the coordinates 1,2,0 at the end of our given amount of time.

If the boat captain continues to steer the boat due north at the same speed 
(0,2,0) the wind will still be blowing due east (1,0,0) and thus again blow the 
boat to the ending coordinates of (1,2,0) again as the next unit of time passes.

We can actually use projection to simulate various forces acting on entities in 
our game world; wind, thrust, gravity, drag, friction. etc.

Let's look at the above projection in a different way now. Instead of the boat 
captain steering the boat against the wind, perhaps the captain is asleep and 
the boat is adrift. Don't worry, we won't let him go very far. :)

So we have our boat starting out moving north at (0,2,0).

We have our wind steadily blowing at (1,0,0).

Project the wind on to the boat's motion and you end up with the boat at (1,2,0)

What happens if the boat simply keeps moving in its new direction?

1,2,0 + 1,0,0 = 2,2,0

Our boat is now moving northeast. -And the wind keeps blowing.

2,2,0 + 1,0,0 = 3,2,0

Our boat is now traveling east-northeast.

This looks right at a glance, but let's look at what's really happening here. 
If you notice, our boat is actually speeding up and our calculations are off.

Even though the above looks like physics, we haven't really taken any physics 
into account here. -And, rather than go into a lot of physics in this note, 
let's stay with a simple aspect of this boat's travel.

In an earlier note I gave the example of a runner continuously accelerating and 
we illustrated this with an ever-increasing vector length. Well if you notice, 
our boat's vector of travel keeps getting longer as the wind keeps blowing. If 
we kept projecting the wind vector on to the boat's travel vector, the x 
coordinate would just keep in creasing and increasing and increasing until our 
boat would basically be traveling faster than any other boat I know of! :) -And 
it still wouldn't stop there! :)

Obviously a wind of only 1 unit over time shouldn't be causing another object 
to go faster and faster and faster.

So what have we missed? We haven't been taking the length or magnitude of our 
vector into account.

So how does this help us?

We know that our boat originally traveled at 2 units over time. So our boat;s 
vector of travel has a magnitude of 2 units. When we project the wind vector on 
to it, we are adding magnitude to the vector.

Remember we ended up with 1,2,0

So rather than leave it there, let's check the magnitude of this vector.

We do this with the Pythagoras theorem.



1 * 1 is 1

2 * 2 is 4

0 * 0 is 0

1 + 4 + 0 is 5

the square root of 5 is 2.23606797749979

2.24 for our uses…

So our boat is now traveling faster than it's usual 2 units. As I said, we can 
take quite a lot into account here but for now let's just go with the idea that 
we really only want our boat ever traveling at 2 units over a given time.

We can magnify our current vector so its length (the boat's velocity) is still 
2 units but traveling in its new direction.

Remember, we do this by dividing our vector by it's current length and then 
multiplying by the length we want it to have.

So this would look like:

1 / 2.24 * 2 = 0.8928

2 / 2.24 * 2 = 1.7857

0 / 2.24 * 2 = 0

So the vector of travel we end up with is:

0.8928,1.7857,0


Okay, so it's just not as pretty as our earlier vectors but the computer 
doesn't care. it will still be able to work with it just as effectively in a 
gaming situation.

So this is actually the new direction and speed of our boat as the wind blows 
it.

NOw we can do more with physics to take into account the energy being imparted 
to the boat from the wind as well as the drag on the boat from the sea and 
such, but for now this should be a fun start!…

Vector projection is a really simple, useful and pretty interesting process to 
play with with your game entities.

Hope this makes sense and is something y'all may be interested in… :)

Have a great weekend and talk with y'all soon!…

Smiles,

Cara :)
---
View my Online Portfolio at:

http://www.onemodelplace.com/CaraQuinn

Follow me on Twitter!

https://twitter.com/ModelCara


---
Gamers mailing list __ [email protected]
If you want to leave the list, send E-mail to [email protected].
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/[email protected].
If you have any questions or concerns regarding the management of the list,
please send E-mail to [email protected].

Reply via email to