Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtquick3dphysics-units.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtquick3dphysics-units.html
6\title Qt Quick 3D Physics Units
7\brief An explanation of how Qt Quick 3D Physics handles units and dimensions.
8
9When 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.
10
11\section1 Default units
12
13Despite the module being unit-less all physical properties have default values that are based on centimeters. This means that adding a sphere with diameter \c 1 would make it behave like it was \c 1 cm in diameter. To be compatible with Qt Quick 3D the default sizes of the built-in geometries are \c 100 cm. The default gravity is \c 981 which matches the gravity on earth in cm per square-second. The default density is \c 0.001 kilograms per cubic-centimeters i.e. \c 1000 kilogram per cubic-meter which is the density of fresh water at \c 4 °C.
14
15\section1 Custom units
16
17Using 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:
18
19\table
20\header
21 \li Property
22 \li Value (cm)
23 \li Value (m)
24\row
25 \li \l {PhysicsWorld::} {gravity}
26 \li \c 981
27 \li \c 9.81
28\row
29 \li \l {PhysicsWorld::} {typicalLength}
30 \li \c 100
31 \li \c 1
32\row
33 \li \l {PhysicsWorld::} {typicalSpeed}
34 \li \c 1000
35 \li \c 10
36\row
37 \li \l {DynamicRigidBody::} {density}
38 \li \c 0.001
39 \li \c 1000
40\endtable
41
42If 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 \c 0.01.
43
44*/