How Many Vectors?

Post: #1
In my 3D game, how many vectors should control my ship's movement? Should I have three vectors total, consisting of location, velocity, and acceleration and simply add them as needed?

In the past I have created a few simple 2D games with nothing more than a vector for location and variables for the speed and degree of my ship. Since my current project is in 3D, however, I'm not sure if such simplicity will be best when I add external forces to the mix (e.g. explosions, gravity, etc...) and then collision detection.

Any advice?
Quote this message in a reply
Posts: 304
Joined: 2002.04
Post: #2
Location, velocity, acceleration - but dont forget orientation and rotation! You can store them as a 3x3 matrix, a quat, hpr (which may not make sense for a space game where you could get gimbal lock) or as an angle-axis.

Is the little appfactory branching out into games? Cool!
Quote this message in a reply
Posts: 749
Joined: 2003.01
Post: #3
you dont need a vector for acceleration. the acceleration impressed to the ship is determined each frame. “Every body perseveres in its state of being at rest or of moving uniformly straight forward except insofar as it is compelled to change by forces impressed.” Good old Isaac. Acceleration is not a state variable.

©h€ck øut µy stuƒƒ åt
New game in development Rubber Ninjas - Mac Games Downloads
Quote this message in a reply
Posts: 2
Joined: 2006.10
Post: #4
Here's what I keep track of for fully-fledged physically-modelled bodies.

// Constant quantities.
    float oneOverM;       // reciprocal mass of body
    Matrix3x3 *IBodyInv;   // inverse of the body-space inertia tensor
    // State variables.
    Vector3 *x;              // position
    Vector3 *p;              // linear momentum
    Vector3 *L;              // angular momentum
    Quaternion *q;           // orientation in quaternion form
    // Auxiliary variables.
    Matrix3x3 *I_inv;        // inverse of real-space inertia tensor
    Vector3 *v;              // linear velocity
    Vector3 *omega;          // angular velocity
    Matrix3x3 *R;            // rotation matrix, derived from q

    // Computed quantities.
    Vector3 *force;          // net force on body
    Vector3 *torque;         // net torque on body
    Vector3 *linearImpulse;      // net linear impulse on body
    Vector3 *rotationalImpulse;  // net rotational impulse on body
Quote this message in a reply
Post Reply