   Steering behaviors problem
  Hi, i try to make a spaceship simulation game and now i working on a steering behaviors of space ship.Before i start code the steering behaviors, i make locomotion functions for my ship. I do that in two ways, with a pitch and yaw functions and second way is witha quaternions and inertia tensor. But in both case i have specific problem.This is the problem: I use one locomotion function that have one parametar, vector of the force from some steering function, in my case, SEEK. My ship have heading vector that points into direction in witch ship looking. It work fine for all points except that behind the ship and colinear with the heading vector. In the other words, if the angle of the heading vector and the target vector is PI (in the plane). If this is a case, my ship goes forward and at one point just turn for PI angle and start to seek target point. I try to solve this with checking case if angle is PI, and use some random angle to turn it, but this make my ship crazy. I look into some other examples of steering behavior in 2D, but this is the same problem. Question 1: Can i just let this thing like it is? Probability for this case is small. I supose that.Question 2: Is there some tutorials for making or modeling starship physic. This is one of the problems i have, but i have feeling that is not last one. :)Thanks for answers..... :)   
  well, I think I understand what you mean, but... Are you using inverse trigonometric functions anywhere? These are the asin(), acos(), atan(). It is common that these produce that sort of problems, because they only return results in [-pi/2, pi/2] for asin(), [0, pi] for acos() and atan() in [-pi/2, pi/2]The fact that it seems to work for points only on the front side of your spaceship (and then suddenly turns by a whole PI radians), makes me think it has to do with this.Are you using atan() anywhere? like atan(y/x) ?If yes, replace it with atan2(y,x). Atan2() checks in which quadrant your point is and returns results in [-pi, pi)   ;  and btw, if you want accurate physics, this TurnToDirection(vector v) approach won't be any realistic at all.Instead, you'll have to calculate all the torques from the forces, taking also into account the point where the force is applied. You can't create rotational effects by simply applying forces at the center of mass. You'll have to integrate the total torque to derive the angular momentum, and then find the angular velocity to integrate (if you know the inertia tensor for your object), in order to find the new angles for your ship's orientation.As you may assume, it's not that easy... but it's not that hard too.I can only link you to a paper that I remember had helped me a great deal back some years ago. I hope you make something of it. I'm sure you'll find many other physics simulations papers, but I believe this one is pretty straight-forward.Don't worry about the math, you don't have to know how to prove these.2D part 1 2D part 2 2D part 3 This one sums it up in 3d3D implementation I hope these point you to the right direction...   ;  I actually made a post about this not 5 minutes ago in another thread, let me quote it for you:Quote:Original post by ZipsterTake a look at Steering Behaviors For Autonomous Characters by Craig Reynolds (the guy who came up with "boids").  He discusses how you can break down different steering strategies into several basic types and then combine them to allow more complex behavior.  For instance, using the terminology in the paper you could devise a "dogfight" behavior that's a combination of Flee and Arrival.  You could use other factors (such as relative strength, health, weapons, etc.) to help compute weights for a linear combination, or some other combination technique.It's just a suggestion, but I've implemented this before and it actually looks quite good for the little amount of effort it takes to implements.  With more time you could probably make it work extremely well for your purposes.  There's a library linked from that page called OpenSteer that has a demo program you can download and play around with.;  hi,thank you for help, first.I use atan2 function, so i think that is no problem, and i supose math is not a problem. I am math student. :)So, when i calculate torque, i have a point where thew force is aplied. That point is somewhere in the back of the ship(where the ship engine is :) ). And in the first step calculate the torque, and make rotation and translation matrix, do i now must rotate and translate the force vector??? I supose that i must, because that vector must be behind the ship.So, how can i see, the force vector rotate my ship. It is logical. And that force vecotr is created or depends of the steer function.  It work all fine.And now is the problem: when the target point lie behind the ship and on the line that is colinear with the heading vector, seek function give me a vector that have oposite direction with heading. Heading vector determines ship orientation. So how can i see, there is no any rotation in this case, because the force vector is determined with seek function? Or i am wrong?Maybe it is an error somewhere, i need to check out it again.Thanks for help and papers 