Sign in to follow this  

Space sim collision - "movement preservation law" vectors

Recommended Posts

Cheers, I'm working on a space sim. Simplified, I currently have a ship's rotation quaterion and velocity. Based on the quaternion, velocity and time since last update, I update the ship position. I've began work on collision detection and bumping. I've been speeding around in my physics schoolbook, and I found the "movement preservation law" (is this the correct name in English?):
// new speed:
//       (m1 - m2) * v1 + 2 m2v2
// v1' = ------------------------
//              m1 + m2
Of course, velocities are -- vectors. And, the rotation quaternion not only keeps the ship movement direction, it's also the cockpit direction. So if I converted velocities to vectors and then back to quaternions + scalars, the ship would start facing wrong direction. Instead the cockpit should keep facing the same direction, just the ship should move in opposite direction, and slowly the movement velocity vector should restore to the original one. If I were to introduce another vector (cockpit direction in addition to ship direction) that would complicate the rotation controls which currently have angular velocity, max angular velocity and angular acceleration, and I just update the quaternion accordingly. I'll eventually think of something (hopefully soon), but I thought it couldn't hurt asking. Asking might even speed up the process :) So -- any hints on how would you do it / how you did it? Note, I'm trying to duplicate behavior of X-BTF, X-Tension, and X^2 - The Threat. Please, no comments on correctness of the ship behavior as is. I'm not aiming for a simulation (despite the genre name), and the current behavior feels natural although it's incorrect. If it works for X, it will work for me.

Share this post

Link to post
Share on other sites
Maybe you could have a deflection velocity that is separate from the direction of the cockpit and have another variable that goes from a 0 to 1 after a collision. That variable could select how much of each vector to derive a final velocity. At 1 it will go in the direction of the cockpit.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this