IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Qt Quick 3D Physics Units

An explanation of how Qt Quick 3D Physics handles units and dimensions.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Qt Quick 3D Physics Units

When simulating physical objects you need to define a common frame of reference for all physical units. In Qt Quick 3D Physics all types are unit-less meaning you can define your world in centimeters, meters, inches or whatever you prefer as long as you are consistent. The important part is that all values used are based on the same units.

Default units

Despite the module being unit-less all physical properties have default values that are based on centimeters. This means that adding a sphere with diameter 1 would make it behave like it was 1 cm in diameter. To be compatible with Qt Quick 3D the default sizes of the built-in geometries are 100 cm. The default gravity is 981 which matches the gravity on earth in cm per square-second. The default density is 0.001 kilograms per cubic-centimeters i.e. 1000 kilogram per cubic-meter which is the density of fresh water at 4 °C.

Custom units

Using custom units is possible but you need to make sure all relevant properties are updated accordingly. Below is a table showing the equivalent values of some properties in both a meter and a centimeter based scale:

Property

Value (cm)

Value (m)

gravity

981

9.81

typicalLength

100

1

typicalSpeed

1000

10

density

0.001

1000

If converting from a centimeter to a meter based scale then all the positions and dimensions of objects as well as impulses and forces would need to be scaled by a factor of 0.01.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+