• Create Account

# Sir David

Member Since 30 Jul 2012
Offline Last Active Aug 05 2012 08:20 AM

### In Topic: Moving a scene/entity in a 3D world.

04 August 2012 - 11:01 AM

Take the previous 3D vector, multiply it by the speed (not velocity) and by time, then add it to the ship’s current 3D vector that represents its position. The position of the ship has now moved in the correct direction by the correct amount.

This makes sense, I think. You're saying that I have one vector at my world origin which gives the ships x, y, z, and after adding the speed*direction*time to the position vector, it's the ship's new position.

You can use a unit vector to store your facing direction.
If you want to turn, rotate the vector.

This I'm not so clear on. Is this unit vector centered about the world origin? I suppose it would be, right? If so, my difficulty now is in adjusting the direction of that unit vector. If the ship's "up" is in the positive Y direction, and the ship is facing the negative X, then when the user turns there ship to the left, I just rotate the facing direction about the Y axis, but I have trouble envisioning how it works when the "up" vector has X and Z components.

I think if I had an explanation and solution for the following problem, that might help.
The ship has a direction described by the vector D=(0.36, 0.59, 0.72)
The ship's "up" direction is described by U=(.62, .75, -.21)
When a user "turns" for time 't', (rotating only about the "up" axis, like turning on a flat road in a car), the ship rotates 'pi/10' radians in the direction turned.
If this ship turns for one time unit, what is its new direction vector?

Even describing the above problem though, I foresee more issues. It seems like the direction vector MUST be centered at the ship's origin because if the direction is centered about the world origin, when the ship turns, and there's a rotation about U by pi/10 at the origin, it won't "feel" like pi/10 for the ship. From the ship's point of view it will turn very quickly at some 't's and very slowly at others based on its position from the world origin.
So there must be some sort of translation between the ship's "reference frame" and the world's.
I'm brand new to all this, so as much as you can dumb down any insight, the better.

To give the above problem a little more practicality with reference to my previous paragraph monologue, consider the following:
The ship's position in the world's reference frame is P=(50, 35, 35).
The ship moves 30 units in direction D before it turns, what is its new position P'?
Now the ship turns for one unit of time and rotates about U by pi/10.
The ship moves another 30 units in it's new direction D'.
Where is the ship's position P'' now?

A detailed solution to this would be GREATLY appreciated. Thank you.

PARTNERS