0% found this document useful (0 votes)
6 views

position based dynamics

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

position based dynamics

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

P

Position Based Dynamics and external forces acting on an object at the


beginning of a time step. Then a numerical inte-
Tsung-Chih Tsai gration technique like explicit or implicit Euler
Fashion Tech, Nogle, Taipei, Taiwan integrator is further applied to estimate new veloc-
ity, and then position at the end of a time step. The
former is conditionally stable and accurate if a
Synonyms small time step is adopted. In contrast, the latter
is unconditionally stable even though a large time
Position based dynamics step is adopted, but inaccurate. In order to achieve
a trade-off between them, position based method
simply adopts a fast semi-integrator, symplectic
Definition Euler, to evaluate external force like gravity. Fur-
thermore, instead of gathering internal forces to
Position based dynamics is a fast, stable, and con- compute acceleration and velocity, the vertex
trollable simulation technique. It directly manipu- position is directly manipulated and controlled to
lates the vertex positions of object meshes instead solve internal constraints, like stretching, bend-
of forces or impulses and can model various ing, or volume constraint, and collision con-
dynamic and interactive effects of objects such as straints such as mutual-collisions between
rigid body, soft body, cloth, or fluids. objects or self-collisions of an object. Conse-
quently, this method does not only bring the
speed and visual plausibility but also the control-
Introduction lability on attached objects or collision handling.
Some well-known real-time physics engines such
Physically based simulation has been an important as PhysX, Bullet, and Havok all have integrated
and active research field in computer graphics. In the position based method into their systems to
recent decade, it has become an indispensable simulate soft body or cloth dynamics.
component in movies, video games, or interactive In this entry, we mainly introduce the position
applications. In addition, with the rapid growth of based dynamics method (PBD), presented by
the computational capabilities of CPUs and GPUs, Müller et al. (2007), and refer to new emerging
there are more and more demands for real-time techniques based on the former.
complicated simulation effects.
The classic simulation method is based on
Newton’s law of motion to accumulate internal
# Springer International Publishing AG 2017
N. Lee (ed.), Encyclopedia of Computer Graphics and Games,
DOI 10.1007/978-3-319-08234-9_92-1
2 Position Based Dynamics

Overview of Algorithm as stretching, bending, or volume constraints.


These constraints are to simulate various object
PBD presented a particle-based model which com- materials like soft body or cloth by building an
bines internal and collision constraints. A deform- equilibrium system which connects different par-
able object is represented by a set of N particles and ticles together based on the constraint type.
a set of M (Minter + Mcoll) constraints including a Instead of adopting a classic mass-spring model
fixed number of internal constraints (Minter) and an to evaluate a force based result, the system
unfixed number of collision constraints (Mcoll). At directly controls the positions and displacements
each time step (Dt), the simulation procedure is of those particles to satisfy the constraint condi-
performed as follows. Before entering the simula- tions. In addition, it also must conserve both linear
tion loop, for all N particles, we initiate the current and angular momentums. This means that any
position (x), velocity (v), and mass (m) of each rotating or translating the particles does not
particle to its beginning variables. change the equality of the constraint function C-
(x + Dx) = 0. Dx stands for the corrected dis-
1. Gather and accumulate external forces (fext(xi)) placements of all particles, i.e., [Dx1, . . . , DxN]T.
acting on particle i. These forces include grav- The constraint function can be further derived
ity and other forces that are unable to be and approximated by the following equation:
converted to position based manipulation.
2. Update new velocity (vi) and predicted position Cðx þ DxÞ  CðxÞ þ ∇x CðxÞ∙Dx ¼ 0
(x0i ) by the symplectic Euler method: vi ¼ vi þ
Dt f extmðixi Þ, and x0i ¼ xi þ Dtvi . where∇xC(x) is a gradient vector and means
the maximal change’s direction. By restricting
3. Perform discrete or continuous collision detec-
Dx to be in the direction of ∇xC(x1, . . . , xN), we
tion to collect all overlapping geometries, and
can derive
generate Mcoll collision constraints (see section
“Collision Constraints”).
Cðx1 , . . . , xN Þ
4. Iteratively solve a set of M constraints one after Dx ¼  ∇x Cðx1 , . . . , xN Þ
another in a Gauss-Seidel type fashion, until j∇x Cðx1 , . . . , xN Þj2
the solver loop reaches the maximal predefined
iteration. While solving a constraint, those pre- Then, for the corrected displacement of an indi-
dicted positions (x0) of particles related to this vidual particle i with an inverse mass wi = 1/mi,
constraint are all corrected to satisfy the con- we have
straint condition (see section “Internal
Constraints”). wi Cðx1 , . . . , xN Þ
Dxi ¼  ∇ Cðx1 , . . . , xN Þ
P
N  2 xi
5. After solving constraint loop, the predicted 
wj ∇xj Cðx1 , . . . , xN Þ 
position(xi0 ) is used to update the velocity (vi) j
accordingly, and then set back to the current
x0 x
position (xi): vi ¼ iDt i , and xi ¼ x0i . In order to represent the stiffness strength of
6. Lastly, these velocities of colliding particles an object material, the stiffness parameter k 
involved in the collision constraints need to [0 . . . 1] is incorporated into the above constraint
be further modified according to friction and function. Then, it becomes
restitution coefficients.
wi Cðx1 , . . . , xN Þ
Dxi ¼ k0 ∇ Cðx1 , . . . , xN Þ
P
N  2 x i

wj ∇xj Cðx1 , . . . , xN Þ 
j
Internal Constraints

An object model does not only consist of a set of where k0= 1  (1  k)1/s and s is the iteration
particles but also a set of internal constraints such count of a constraint solver. Instead of directly
Position Based Dynamics 3

multiplying Dxi by k, k0 makes k independent of angle between T1 and T2. The gradient ∇xC(x1,
the solver and more predictable. . . . , x4) shows as follows:

x2  n1 þ ðn2  x2 Þd
Stretching Constraint ∇x4 Cðx1 , . . . , x4 Þ ¼
jx2  x4 j
For each edge of a triangle mesh, a stretching
constraint is built to control the movement of x2  n2 þ ðn1  x2 Þd
∇x3 Cðx1 , . . . , x4 Þ ¼
both its vertices, x1 and x2. This constraint can jx2  x3 j
be represented as a distance constraint function
C(x1, x2) = |x1  x2|  d, where the scalar x3  n2 þ ðn1  x3 Þd
∇x2 Cðx1 , . . . , x4 Þ ¼ 
value d is the initial distance between x1 and x2. jx2  x3 j
Such as Fig. 1, both vertices are projected to x4  n1 þ ðn2  x4 Þd
the direction of gradient vector ∇xC(x1, x2), i.e., 
jx2  x4 j
∇x1 Cðx1 , x2 Þ ¼ n , and ∇x2 Cðx1 , x2 Þ ¼ n ,
with n = (x1  x2)/jx1  x2j. Thus, we can get ∇x1 Cðx1 , . . . , x4 Þ ¼ ∇x2 Cðx1 , . . . , x4 Þ
the final displacements as follows:
∇x3 Cðx1 , . . . , x4 Þ∇x4 Cðx1 , . . . , x4 Þ
w1 Cðx1 , x2 Þ
Dx1 ¼  ∙ where d = n1 ∙ n2. Then the final correction Dxi is
P
2  2
wj ∇xj Cðx1 , x2 Þ as follows:
j¼1
pffiffiffiffiffiffiffiffiffiffiffiffiffi
w 1 ðj x1  x 2 j  d Þ x1  x 2 wi 1  d2 Cðx1 , . . . , x4 Þ
n¼ ∙ Dxi ¼  4 ∙∇ Cðx1 , . . . , x4 Þ
w1 þ w2 j x1  x2 j P   2 xi
wj ∇xj Cðx1 , . . . , x4 Þ 
j¼1
w2 Cðx1 , x2 Þ
Dx2 ¼ þ ∙
P 
2 2

wj ∇xj Cðx1 , x2 Þ Volume Constraint
j¼1
For each closed triangle mesh, a volume con-
w 2 ðj x1  x 2 j  d Þ x1  x 2 straint is built to maintain its volume and pressure.
n¼þ ∙
w1 þ w2 j x1  x2 j This constraint function refers to all N particles of
the mesh.
!
l 
X 
Bending Constraint C ðx 1 , . . . , x N Þ ¼ xti1  xti2 ∙xti3
For each pair of adjacent triangles T1(x1, x2, x3) i¼1
and T2(x1, x4, x2) such as Fig. 2, we generate a  kpressure V 0
bending constraint with constraint function:
Here l is the amount of all triangles. xti1 , xti2 , and
Cðx1 , x2 , x3 , x4 Þ ¼ cos 1 ðn1 ∙n2 Þ  j0 xti3 represent the three particles of triangle

where n1 ¼ jððxx22 x 1 Þðx3 x1 Þ


x1 Þðx3 x1 Þj , n2 ¼
ðx4 x1 Þðx2 x1 Þ
jðx4 x1 Þðx2 x1 Þj , and j0 is the initial dihedral

Position Based Dynamics, Fig. 1 The projection of


distance constraint Position Based Dynamics, Fig. 2 Bending constraint
4 Position Based Dynamics

i respectively. kpressure is a pressure factor and used particle potentially overlaps with any triangles by
to simulate overpressure status, and V0 is the checking the same hash index.
original volume of the closed mesh. Furthermore, As for the collision detection between deform-
we can derive the gradient vector xi Cðx1 , . . . , xN Þ : able objects and rigid bodies, bounding volume
hierarchy (BVH) (Gottschalk et al. 1996) is built
X 
∇xi Cðx1 , . . . , xN Þ ¼ xt j  xt j and maintained to speed up the process of culling
2 3
j:t j1 ¼i
nonoverlapping parts of the objects. BVH is a tree
X  data structure, and constructed by recursively
þ xt j  xt j dividing objects into subsets of geometric primi-
3 1
j:t j2 ¼i tives. In the meantime, these primitives are
X  enclosed into simple bounding volumes, like
þ xt j  xt j spheres, AABB, OBB, or k-DOP and stored into
1 2
j:t j3 ¼i the corresponding tree nodes. By doing the tree
traversal recursively and performing simple over-
where j : t j1 ¼ i, j : t j2 ¼ i, and j : t j3 ¼ i are the lapping tests among bounding volumes, it does
triangle indices containing xi in first, second, and not only simplify the collision computations but
third place, respectively. also reduces the number of collision pairs.
Once a vertex-triangle pair has been detected,
continuous collision handling (Müller et al. 2007)
Collision Constraints is then used to check if the vertex has penetrated
into the triangle. We shoot a ray (xi ! xi0) for
Unlike internal constraints (Minter) which are gen- vertex i to perform a ray-triangle intersection
erated once before simulation, collision con- test. If this ray hits the triangle, we compute the
straints (Mcoll) are detected and generated at each hit point xhit and the triangle’s surface normal nhit
time step before entering the constraint solver at this position and judge whether the inequality
loop. In other words, the number of collision constraint function is satisfied:
constraints varies and depends on actual colliding
particles. A collision constraint C(xv, xt1, xt2, xt3) Cðxv , xt1 , xt2 , xt3 Þ ¼ ðxv  xhit Þ  nhit  h > 0:
is generated and inserted into the system if the
vertex (xv) hits or penetrates into another triangle Here h is a collision margin or surface thick-
(xt1 , xt2 , xt3). Also, due the collision constraint is ness value. When the above constraint is solved,
an inequality constraint, it will not be performed we can compute the correction Dxv = h  (xv 
if the collision does not satisfy the condition of xhit) ∙ nhit. If the ray hits the front side of the
C(x1, . . . , xN) < 0. There are both continuous triangle, nhit is computed as follows:
collision and static collision handling methods
ðxt2  xt1 Þ  ðxt3  xt1 Þ
used to solve different collision cases (Müller nhit ¼
et al. 2007). jðxt2  xt1 Þ  ðxt3  xt1 Þj
In order to efficiently detect potential collision
and self-collision pairs of deformable objects, a In contrast, if the ray hits the back side of the
spatial hashing table (Teschner et al. 2003) is triangle, then we get
built. It can early exclude most of collision pairs
which are not colliding with each other. Firstly, ðxt3  xt1 Þ  ðxt2  xt1 Þ
nhit ¼
the predicted positions of particles and AABBs of jðxt3  xt1 Þ  ðxt2  xt1 Þj
triangles are discretized to 3D cell indices with
respect to a predefined grid cell size. Then, these When a ray is completely inside a closed
cell indices are further mapped into 1D hash object, continuous collision handling does not
index. Lastly, we are able to quickly detect if a work at this case. At this moment, we apply static
Position Based Dynamics 5

collision handling (Müller et al. 2007) to compute constant density. It allows similar incompressibility
the surface point xs, which is closest to xv, and the and convergence to modern smoothed particle
surface normal ns at this position. Lastly, we can hydrodynamic (SPH) solvers (Monaghan 1992).
have a modified correction Dxv: Macklin et al. (2014) modeled gases, liquids,
deformable solids, rigid bodies, and cloth as
Dxv ¼ h  ðxv  xs Þ∙ particle-based models connected by constraints.
ðxt3  xt1 Þ  ðxt2  xt1 Þ Also, they treat contact and collisions in a unified
ns ¼ h  ðxv  xs Þ∙ manner so as to support two-way interactions with
jðxt3  xt1 Þ  ðxt2  xt1 Þj
one another.
For the collision handling between deformable
objects and rigid bodies, if we need two-way
interactions, a correction Dxv is applied to a Cross-References
deformable vertex. Also, an impulse miDxv /Dt is
simultaneously applied to the rigid body at the hit ▶ Collision Detection
point. ▶ Deformable Models
▶ Explicit Methods
▶ Fluid Simulation
The Future ▶ Implicit Methods

Although position based dynamics is fast, stable,


and controllable, it has some limits. The Gauss- References
Seidel type solver handles constraints one by one
individually such that the information propaga- Deul, C., Charrier, P., Bender, J.: Position-based rigid body
dynamics. Comput. Anim. Virtual Worlds. 27(2),
tion is slow and hard to converge. Consequently,
103-112(2014)
it makes deformable object stretchier and results Gottschalk, S., Lin, M. C., Manocha, D.: Obbtree: a hier-
in an obvious visual defect, especially when high- archical structure for rapid interference detection.
resolution meshes are used. Wang (2015) applied In: Proceedings of the 23rd Annual Conference on
Computer Graphics and Interactive Techniques,
a Chebyshev semi-iterative approach to accelerate
pp. 171–180 (1996)
the convergence. Macklin, M., Müller, M.: Position based fluids. ACM
Another limit is that the constraint stiffness Trans. Graph. 32(4), 104:1–104:12 (2013)
cannot be completely controlled by the user- Macklin, M., Müller, M., Chentanez, N., Kim, T. Y.:
Unified particle physics for real-time applications.
defined parameter. It also depends on both the
ACM Trans. Graph. 33(4), 153:1-153:12(2014).
time step size and the number of solver iterations. Macklin, M., Müller, M., Chentanez, N.: Xpbd: Position-
Specifically, constraints become stiffer and stiffer based simulation of compliant constrained dynamics.
as the number of solver iterations increases, or as In: Proceedings of the 9th International Conference on
Motion in Games, pp. 49–54 (2016)
the time step size decreases. Recently, Macklin
Monaghan, J. J.: Smoothed particle hydrodynamics. Annu.
et al. (2016) introduced a total Lagrange multi- Rev. Astron. Astrophys. 30( 1), 543-574 (1992).
plier to PBD and allowed solving constraints to be Müller, M., Heidelberger, B., Hennix, M., Ratcliff, J.:
independent of the above factors. Position based dynamics. J. Vis. Commun. Image Rep-
resent. 18(2), 109-118(2007)
The position based simulation method is not
Teschner, M., Heidelberger, B., Müller, M., Pomeranerts,
limited to particle-based models. It also has been D., Gross M.: Optimized spatial hashing for collision
used to simulate articulated rigid body systems with detection of deformable objects. In: Proceedings of the
joint and contact constraints (Deul et al. 2014). Vision, Modeling, and Visualization Conference,
pp. 47–54 (2003)
Macklin and Müller (2013) presented an itera-
Wang, H.: A chebyshev semi-iterative approach for accel-
tive density constraint solver by formulating and erating projective and position-based dynamics. ACM
solving a set of positional constraints that enforce Trans. Graph. 34(6), 246(2015).

You might also like