赞
踩
本书以 基于物理的建模与动画(Foundations of Physically Based Modeling and Animation) 为textbook
four parts
Euler method
For a point ( x 0 , y 0 , z 0 ) (x_0, y_0, z_0) (x0,y0,z0) and a plane A x + B y + C z = 0 Ax + By + Cz = 0 Ax+By+Cz=0, we can use the value of P ( x 0 , y 0 , z 0 ) = A x 0 + B y 0 + C z 0 P(x_0, y_0, z_0) = Ax_0 + By_0 + Cz_0 P(x0,y0,z0)=Ax0+By0+Cz0 to determine which side the point belongs.
Another common method is to use normal vector
n
^
=
[
n
x
n
y
n
z
]
T
\hat{n} = [n_x\ n_y\ n_z]^T
n^=[nx ny nz]Tand a point
p
(
p
x
,
p
y
,
p
z
)
p(p_x,p_y,p_z)
p(px,py,pz) on the plane.
These variables can construct a plane like
n
x
x
+
n
y
y
+
n
z
z
−
n
^
⋅
p
=
0
n_x x + n_y y + n_z z - \bm{\hat{n}} \cdot \bm{p} = 0
nxx+nyy+nzz−n^⋅p=0, or in concise terms
(
x
−
p
)
⋅
n
^
=
0
(\bm{x} - \bm{p}) \cdot \bm{\hat{n}} = 0
(x−p)⋅n^=0
The projection distance from point to plane can be got by
d
=
(
x
−
p
)
⋅
n
^
d = (\bm{x} - \bm{p}) \cdot \bm{\hat{n}}
d=(x−p)⋅n^
The following is got by Euler method
We use
d
[
n
]
d^{[n]}
d[n] denotes the projection distance timestep begins, and
d
[
n
+
1
]
d^{[n+1]}
d[n+1] denotes timestep ends.
We suppose that the velocity is constant in the duration.(Euler method)
So we can get the timestep fraction
f
=
d
[
n
]
d
[
n
]
−
d
[
n
+
1
]
f = \frac{d^{[n]}}{d^{[n]} - d^{[n + 1]}}
f=d[n]−d[n+1]d[n],
and the timestep when the collision occurs in this turn is
f
h
fh
fh.
Using this,we get the new state and calculate the remain timestep.
pseudo code: h is timestep, n is step, t is current time, s is state s = s0, n = 0, t = 0; while t < tmax do { TimestepRemaining = h; Timestep = TimestepRemaining; while TimestepRemaining > 0 { s_deriv = GetDeriv(S); s_new = Intergate(s, s_deriv, Timestep); if CollisionBetween(s, s_new) { calcuate f; // f means timestep fraction Timestep_collision = f * Timestep; s_new = Intergate(s, s_deriv, Timestep_collision); CollisionResponse(s_new); } TimestepRemaining = TimestepRemaining - Timestep; s = s_new; } n = n + 1, t = n * h; }
In this chapter, we simplify the siutuation and suppose there is no rotation and the plane is infinite.
The collision response can be devided two parts, elasticity & friction.Here we use
−
\bm{^{-}}
− to denote the state before collision,
+
\bm{^{+}}
+ to denote the state after collision.
From the sumption, we know
x
−
=
x
+
x^{-} = x^{+}
x−=x+, and we want to get
v
+
v^{+}
v+ from
v
−
v^{-}
v−
Let
n
^
\bm{\hat{n}}
n^ denote the normal factor, we know
v
n
−
=
(
v
−
⋅
n
^
)
n
^
,
v
t
−
=
v
−
−
v
n
−
\bm{v_n^{-} }= (\bm{v^{-}} \cdot \bm{\hat{n}}) \bm{\hat{n}}, \bm{v_t^{-}} = \bm{v^{-}} - \bm{v_n^{-}}
vn−=(v−⋅n^)n^,vt−=v−−vn−
coefficient of restitution
c
r
c_r
cr
v
n
+
=
−
c
r
v
n
−
=
−
c
r
(
v
−
⋅
n
^
)
n
^
\bm{v_n^{+}} = -c_r\bm{v_n^{-}} = -c_r(\bm{v^{-}} \cdot \bm{\hat{n}}) \bm{\hat{n}}
vn+=−crvn−=−cr(v−⋅n^)n^
coefficient of friction
c
f
c_f
cf
v
t
+
=
(
1
−
c
f
)
v
t
−
=
(
1
−
c
f
)
(
v
−
−
v
n
−
)
\bm{v_t^{+}} = (1 - c_f) \bm{v_t^{-}} = (1 - c_f) (\bm{v^{-}} - \bm{v_n^{-}} )
vt+=(1−cf)vt−=(1−cf)(v−−vn−)
Another point to be considerated is the bound of
v
t
+
⩾
0
\bm{v_t^{+}} \geqslant 0
vt+⩾0
v
t
+
=
v
t
−
−
m
i
n
(
μ
∣
∣
v
n
−
∣
∣
,
∣
∣
v
t
−
∣
∣
)
v
t
−
^
\bm{v_{t}^{+}} = \bm{v_{t}^{-}} - min(\mu||\bm{v_{n}^{-}}||, ||\bm{v_{t}^{-}}||) \hat{\bm{v_{t}^{-}}}
vt+=vt−−min(μ∣∣vn−∣∣,∣∣vt−∣∣)vt−^
then we can get the final v + = v n + + v t + \bm{v^{+}} = \bm{v_{n}^{+}} + \bm{v_{t}^{+}} v+=vn++vt+
The problem we face in this stage is numberical precision & resting condition.
a useful method is to avoid round-off error is tolerance.
a
−
b
=
0
⇒
a
>
b
−
ϵ
a - b = 0 \Rightarrow a \gt b - \epsilon
a−b=0⇒a>b−ϵ &
a
<
b
+
ϵ
a \lt b + \epsilon
a<b+ϵ
a
>
b
⇒
a
−
b
>
ϵ
a \gt b \Rightarrow a - b \gt \epsilon
a>b⇒a−b>ϵ
a
<
b
⇒
a
−
b
<
−
ϵ
a \lt b \Rightarrow a - b \lt -\epsilon
a<b⇒a−b<−ϵ
While tolerance still has two limitis.
Four steps:
However, in complex simulations, it’s a NP-complete problem to calculate accurately.More content is in Chapter Nine.
The actual situation is that the plane is finite.
A plane can be uniquely represented by normal vector
n
^
\bm{\hat{n}}
n^ and a point
p
\bm{p}
p on plane.
n
^
=
(
p
1
−
p
0
)
∗
(
p
2
−
p
0
)
∣
∣
(
p
1
−
p
0
)
∗
(
p
2
−
p
0
)
∣
∣
\bm{\hat{n}} = \frac{(\bm{p}_1 - \bm{p}_0) * (\bm{p}_2 - \bm{p}_0)}{||(\bm{p}_1 - \bm{p}_0) * (\bm{p}_2 - \bm{p}_0)||}
n^=∣∣(p1−p0)∗(p2−p0)∣∣(p1−p0)∗(p2−p0)
Let
p
=
p
0
\bm{p} = \bm{p}_0
p=p0 (
p
0
\bm{p}_0
p0 is a point on the plane, or vertex of polygonal geometry particularly)
The distance from point
x
\bm{x}
x to the plane can be represented by
d
=
(
x
−
p
)
⋅
n
^
d = (\bm{x} - \bm{p}) \cdot \bm{\hat{n}}
d=(x−p)⋅n^
All the point on the plane satisfy
(
x
−
p
)
⋅
n
^
=
0
(\bm{x} - \bm{p}) \cdot \bm{\hat{n}} = 0
(x−p)⋅n^=0
3.3.1 P31 tolerance ϵ \epsilon ϵ, a − b > ϵ a - b \gt \epsilon a−b>ϵ
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。