# Vector Maths to Simulate Car Physics [closed]

I'm working on a 3D program that involves controlling a Cube on-screen (which represents a car).

I use C++, OpenGL and GLM (for vector and matrices etc, if you're familiar with programming; Once the car rotates (or steers), I wish to make its direction change and follow the new path... ).

I would like to know the equations to simulate steering (one force at a time, starting with the basic)... I've read lots about velocity vectors and multiplying by the sin/cos of the angle to find it's new path...

My question is, how can this be represented using vectors? And what are the equations/vectors need to simulate basic car movement?

-

## closed as too broad by ja72, Brandon Enright, tpg2114, centralcharge, Qmechanic♦Nov 15 '13 at 12:00

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Depending on the level of realism you need it gets reeeeeally complex really fast. The simplest steerable model is basically a two wheeler with steering front wheel, that never falls over. If you are not familiar with 3D rotations and vector operations (like cross products) it will be impossible for you to do this and for it to feel correct. – ja72 Nov 14 '13 at 23:08
Yes, that's the basic concept I'm looking for at the moment. Just steering. No speeding up, gravity, friction or other forces just yet. I am familiar with functions such as cross product, but no expert, hence learning :) I think once I see the equations for any basic vectors involved I'll be able to program it... – Reanimation Nov 14 '13 at 23:35
Is this a planar or 3D simulation? Is the ground flat in general? – ja72 Nov 15 '13 at 1:43
Well, the graphics are 3D, but yes, planar in a way. I was thinking the steering (seems it's just that and no other forces) could be done as if it were 2D like old school birds-eye view games or something... But I think the vector math is pretty much the same isn't it? – Reanimation Nov 15 '13 at 1:52
The difference is how do you keep track of the orientation of the car. Is there only 1 angle (2D), or 3 angles (3D). – ja72 Nov 15 '13 at 1:58

To a large extent, steering doesn't impact the speed of the vehicle, so you can start with an acceleration vector that is orthogonal to the velocity vector and has magnitude $\frac{v^2}{r}$, where $r$ is the turning radius. Now since $r$ is unknown, it's enough to say that you are going to have an acceleration vector of some magnitude that is orthogonal to the velocity vector.
Now comes for some geometry. Suppose you have a front-wheel vehicle of length $l$ and wheel radius $r_w$, in which the front wheels are turned an angle $\theta$ away from their normal position. Your aim is then to determine the radius of the circle that the car will drive around. Note that both wheels must slip to a certain degree transversely to their direction of travel for turning to occur. You may want to neglect this slippage to a certain extent, although it will make your calculation inaccurate for tight turns. To a first approximation, where the lines going through the front and rear axles intersect is the point around which the vehicle is turning, so that gives you $r$. Like I said, this is not going to be accurate for tight turns because the front and rear axles do not behave symmetrically.
To get a bit more accuracy for tight turns, you can figure out how far the vehicle moves forward when the front wheels move a distance $x$, i.e., $x\cos\theta$. This is how much the rear wheels move by in the forward direction. Now the front of the vehicle has been displaced $(x\sin\theta, x\cos\theta)$ while the rear has been displaced $(0, x\cos\theta)$ (in the coordinate frame of the car). With these two displacement vectors and the length of the car, you can again determine the turning radius $r$.
However, for tight turns, it is no longer true that the driver is facing tangent to the circle along which he/she is turning (picture the unphysical $\theta = 90$). In this case it is simpler just to use the wheel displacements as your displacement vectors for the car. In other words, at each time step, displace the front and rear wheels as given above, where $x$ is $r_w \omega \Delta t$ and $\omega$ is the angular velocity of the front wheels. The line connecting the final positions of the wheels determines the new orientation of the driver.