I am currently experimenting with some physical toys in XNA using the Farseer Physics library, however my question is not specific to XNA or Farseer, but to any 2D physics library.
I would like to add “rocket” movement (I say rocket-like in the sense that it should not be a rocket - it can be a plane or a boat on the water or any number of similar situations) for some objects in my 2D scene. I know how to implement this using kinematic modeling, but I want to implement it using dynamic modeling (i.e., using forces over time). I kind of lost how to implement this.
To simplify the situation, I do not need dynamics to rotate the geometry, just to affect the speed of the body. I use circle geometry that doesn't spin in Farseer, so I’m only interested in the speed of the object.
I'm not even sure what the best abstraction should be. It is clear that I have a direction in which the body moves (a unit vector), a direction in which I want, and a value showing how quickly I want it to change direction, keeping the speed relatively constant (small variations are acceptable).
I could use this abstraction directly or use something like a “rudder” value that controls how quickly an object changes direction (clockwise or counterclockwise).
What forces should I apply to the body to simulate the movement that I am looking for? Keep in mind that I would also like to tune the “thrust” of the rocket on the fly.
Edit: The way I see it, and correct me, if I'm wrong, you have two forces (now ignoring the main force of the axial impact):
1) You have a static “fin” that always points in the same direction as the body. If the body rotates so that the fin is not aligned with the direction of movement, air resistance will apply forces to the length of the rib, proportional to the angle between the direction of movement and the fin.
2) You have a “steering wheel” that can rotate freely within a given range, which is attached at some distance from the center of mass of the body (in this case we have a circle). Again, when this plane is not parallel to the direction of movement, air resistance causes proportional forces along the length of the rudder.
My question, in other words, how can I calculate these proportional forces from the air resistance against the fin and rudder?
Edit: For reference, here is some code that I wrote to verify the accepted answer:
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { float dc = 0.001f; float lc = 0.025f; float angle = MathHelper.ToRadians(45); Vector2 vel = new Vector2(1, 0); Vector2 pos = new Vector2(0, 0); for (int i = 0; i < 200; i++) { Vector2 drag = vel * angle * dc; Vector2 sideForce = angle * lc * vel; //sideForce = new Vector2(sideForce.Y, -sideForce.X); // rotate 90 degrees CW sideForce = new Vector2(-sideForce.Y, sideForce.X); // rotate 90 degrees CCW vel = vel + (-drag) + sideForce; pos = pos + vel; if(i % 10 == 0) System.Console.WriteLine("{0}\t{1}\t{2}", pos.X, pos.Y, vel.Length()); } }
When plotting the output of this program, you will see a nice smooth circular curve, which is exactly what I was looking for!