• Create Account

# jujunosuke

Member Since 14 Jun 2010
Offline Last Active Oct 23 2013 12:53 AM

### #4986995[Car Physics] Sharing work, ideas, formulas and car parameters

Posted by on 04 October 2012 - 08:24 PM

About suspension and weight transfer, i don't know if the solution i used can help any of you guys.
It is just a simplification of the concept, but honestly, i got pretty decent result and my simulation got better.

As kunos said, i use physX as my physics engine, with 5 rigid body connected with joints.
Basically i calculate the spring compression based on the distance of center of my wheel to the distance of my spring attached to the body of the car.
You can decide about the spring distance free height. I set mine to 0.36 meters.
That mean, if the car body is 0 kg the spring should not be compressed and give you 0.36 meters.

Then i just do some calculation of the distance. Vector3 of the center of the wheel, Vector3 of the joint position.
I then make calculation to get a result between 0 and 1.

0 mean that the spring is stretched to the max and give 0 grip. (spring free height)
1 mean that the spring is compressed to the max and give 100 % of grip.

once you made that, calculate the total force that your tire should provide and multiply it by the result of the spring compression.

Works decently for me and was really simple to implement.
But of course, this technique is valuable only if you use a 3d physics engine as mentioned.

### #4793299Aircraft Lateral axis angle

Posted by on 01 April 2011 - 04:21 PM

Hi all !
This is the next step of my previous post here :
http://www.gamedev.n...ft-orientation/

This time, i am having trouble to find the Lateral Axis orientation on my aircraft.
I am very surprise because i apply exactly the same technique as the longitudinal axis so i don't know what is wrong.

Here is how i proceed to find the Angle of my aircraft in comparison with the earth lateral axis.

```var aircraftLateralAxis:Vector3D = aircraft.transform.right;
var worldLateralAxis:Vector3D = aircraft.transform.right.copy();
worldLateralAxis.y = 0;
aircraftLateralAxis.normalize();
worldLateralAxis.normalize();
var dotProduct:Number = aircraftLateralAxis.dot( worldLateralAxis );
var resultAngle:Number = Math.acos( dotProduct );
return resultAngle  / Math.PI * 180;
```

If my longitudinal axis is 0, it works perfectly.
But the more i increase the longitudinal axis (pitch rotation) and the more the lateral rotation look strange. (very hard to explain, so look at the demo)

You can look at my demo example here :

http://www.timelessc...ab/sl/main.html
On the top left corner, you have the angle in degrees.
first click on the screen to activate keyboard. then use arrows.. refresh page to refresh demo.

Any idea on this ?

### #4791129Jet Physics - Aircraft orientation ?

Posted by on 27 March 2011 - 05:16 PM

You are right, but the solution is exactly what you wrote in the second message.

Anyway, here is the final code for those who are interested :

In fact after searching in the 3dEngine documentation, the transform.forward vector had an error in the code.
So i looked at the last update and the correct version was updated. (Flash 3D Engines are very good but still very young).

```var aircraftLongitudinalVector:Number3D = aircraft.transform.forward;
var worldLongitudinalVector:Number3D = new Number3D();
worldLongitudinalVector.clone( aircraftLongitudinalVector ); // important to clone the vector here, otherwise "worldLongitudinalVector.y = 0" will override aircraftLongitudinalVector.
worldLongitudinalVector.y = 0;
//Normalize both vectors
aircraftLongitudinalVector.normalize();
worldLongitudinalVector.normalize();
//Create the dot product
var dotProduct:Number  = aircraftLongitudinalVector.dot( worldLongitudinalVector );
return Math.acos( dotProduct ) * 180 / Math.PI ;// The basic angle is in radians, so * 180 / Math.PI transform it in degrees.
```

Hope this help.
Thanks again for those who helped me.
Regards.

PARTNERS