关节动画
考虑内部骨架的运动,考虑的是运动学上的控制,不考虑引起运动的力,区别于动力学
用于人物、动物运动或者非人物的拟人化控制
基本概念
- 关节:如果两个刚体互相连接且能够发生相对运动,则这两个刚体的关联部分称为关节
- 关节链:将一系列一次相连的刚体通过关节连接而成的开链
- 链杆:关节链中每一段刚体
- 基结点:关节链的起点
- **末端影响器 **:关节链的自由末端(End effector)
- 状态空间:关节链结构所有可能状态的向量空间
- 状态向量:状态空间中的向量
- 关节链结构的自由度(Degree of freedom - DOF):完全确定关节链结构状态所需的独立变量个数
- 单个自由度关节:允许在一个方向上运动
- 复杂关节:大于一个自由度的关节
正向运动学
如何从给定的状态向量计算各个链杆的位置,尤其是末端影响器的位置
动画师通过直接指定关节处的关节运动参数来控制物体的运动
计算方法
基本思想:分段计算结果
说明:θ以逆时针为正,C位末端影响器,状态空间 ( θ 1 θ 2 θ 3 ) \left(\begin{matrix}\theta_1 \\ \theta_2\\ \theta_3\end{matrix}\right) ⎝⎛θ1θ2θ3⎠⎞
分段计算可以获得如下函数:
{
x
C
=
L
1
c
o
s
θ
1
+
L
2
c
o
s
(
θ
1
+
θ
2
)
+
L
3
c
o
s
(
θ
1
+
θ
2
+
θ
3
)
y
C
=
L
1
s
i
n
θ
1
+
L
2
s
i
n
(
θ
1
+
θ
2
)
+
L
3
s
i
n
(
θ
1
+
θ
2
+
θ
3
)
\begin{cases}x_C=L_1cos\theta_1+L_2cos(\theta_1+\theta_2)+L_3cos(\theta_1+\theta_2+\theta_3)\\ y_C=L_1sin\theta_1+L_2sin(\theta_1+\theta_2)+L_3sin(\theta_1+\theta_2+\theta_3) \end{cases}
{xC=L1cosθ1+L2cos(θ1+θ2)+L3cos(θ1+θ2+θ3)yC=L1sinθ1+L2sin(θ1+θ2)+L3sin(θ1+θ2+θ3)
如果用齐次坐标表示
(
x
y
1
)
=
M
1
,
2
M
1
,
1
M
2
,
2
M
2
,
1
M
3
,
2
M
3
,
1
O
其
中
O
=
[
θ
1
θ
2
θ
3
]
,
M
3
,
1
=
[
1
0
L
3
0
1
0
0
0
1
]
,
M
3
,
2
=
[
c
o
s
θ
3
−
s
i
n
θ
3
0
s
i
n
θ
3
c
o
s
θ
3
0
0
0
1
]
\left(\begin{matrix} x\\y\\1 \end{matrix}\right)=M_{1,2}M_{1,1}M_{2,2}M_{2,1}M_{3,2}M_{3,1}O\\ 其中 O=\left[\begin{matrix}\theta_1 \\ \theta_2\\\theta_3\end{matrix}\right], M_{3,1}=\left[ \begin{matrix} 1 & 0 & L_3\\ 0 & 1 & 0\\ 0 & 0 &1 \end{matrix} \right], M_{3,2}= \left[ \begin{matrix} cos\theta_3 & -sin\theta_3 & 0\\ sin\theta_3 & cos\theta_3 & 0\\ 0 & 0 &1 \end{matrix} \right]
⎝⎛xy1⎠⎞=M1,2M1,1M2,2M2,1M3,2M3,1O其中O=⎣⎡θ1θ2θ3⎦⎤,M3,1=⎣⎡100010L301⎦⎤,M3,2=⎣⎡cosθ3sinθ30−sinθ3cosθ30001⎦⎤
逆向动力学
以目标驱动,如何从末端位置 计算状态向量的位置
意义:动画设计者只需要控制末端位置,而不需要控制整个关节链结构,从而简化动画设计。动画师可以不用从头到尾调试,可只精调生成的结果
计算方法
根据末端影响器位置进行插值运算
通过计算正向动力学的方程(组)求出解
- 解析法(适用于简单系统)
- 数值计算(常见Jacobian)
存在困难:
- 求解有0个、一个或多个:过约束系统(存在过多限制条件且不存在对应解)、欠约束系统(系统约束较少且存在多个解)
- 奇异问题:在一条直线上
解析法
已知:末端影响器位置(X,Y),链杆长度: L 1 , L 2 L_1,L_2 L1,L2
可达空间 L 1 − L 2 ≤ X 2 + Y 2 ≤ L 1 + L 2 L_1 -L_2 \leq \sqrt{X^2+Y^2} \leq L_1+L_2 L1−L2≤X2+Y2≤L1+L2
使用余弦定理求解
θ T = a r c c o s ( X X 2 + Y 2 ) θ 1 = a r c c o s ( L 1 2 + ( X 2 + Y 2 ) − L 2 2 2 L 1 X 2 + Y 2 ) + θ T θ 2 = a r c c o s ( L 1 2 + L 2 2 − ( X 2 + Y 2 ) 2 L 1 L 2 ) \theta_T=arccos(\frac{X}{\sqrt{X^2+Y^2}})\\ \theta_1=arccos(\frac{L_1^2+(X^2+Y^2)-L_2^2}{2L_1\sqrt{X^2+Y^2}})+\theta_T\\ \theta_2=arccos(\frac{L_1^2+L_2^2-(X^2+Y^2)}{2L_1L_2}) θT=arccos(X2+Y2X)θ1=arccos(2L1X2+Y2L12+(X2+Y2)−L22)+θTθ2=arccos(2L1L2L12+L22−(X2+Y2))
Jacobian法
使用牛顿迭代法
`
求解发 f ( x ) = 0 f(x)=0 f(x)=0
(1)选择接近函数 f ( x ) f(x) f(x)零点的值 x 0 x_0 x0
(2)计算 f ( x 0 ) f(x_0) f(x0)和切线斜率 f ′ ( x 0 ) f'(x_0) f′(x0)
(3)计算经过 ( x 0 , f ( x 0 ) ) (x_0,f(x_0)) (x0,f(x0))并且斜率位 f ′ ( x 0 ) f'(x_0) f′(x0)的直线和 x x x轴的交点 x 1 x_1 x1: f ( x 0 ) = ( x 0 − x ) ∗ f ′ ( x 0 ) f(x_0)=(x_0-x)*f'(x_0) f(x0)=(x0−x)∗f′(x0)
(4)可推出迭代公式 x n + 1 = x n − f ( x n ) f ′ ( x n ) x_{n+1}=x_n - \frac{f(x_n)}{f'(x_n)} xn+1=xn−f′(xn)f(xn),并利用迭代公式去逼近最优解
牛顿迭代法收敛速度很快,能以较快速度不断靠近方程的根,但是不能保证最优解,只是计算方程的一个近似值
以三链杆关节链为例
-
构建函数
根据之前正向动力学所得的方程组构建函数, θ 1 , θ 2 , θ 3 \theta_1,\theta_2,\theta_3 θ1,θ2,θ3为自变量
{ f 1 ( θ 1 , θ 2 , θ 3 ) = L 1 c o s θ 1 + L 2 c o s ( θ 1 + θ 2 ) + L 3 c o s ( θ 1 + θ 2 + θ 3 ) − x f 2 ( θ 1 , θ 2 , θ 3 ) = L 1 s i n θ 1 + L 2 s i n ( θ 1 + θ 2 ) + L 3 s i n ( θ 1 + θ 2 + θ 3 ) − y \begin{cases} f_1(\theta_1,\theta_2,\theta_3)=L_1cos\theta_1+L_2cos(\theta_1+\theta_2)+L_3cos(\theta_1+\theta_2+\theta_3)-x\\ f_2(\theta_1,\theta_2,\theta_3)=L_1sin\theta_1+L_2sin(\theta_1+\theta_2)+L_3sin(\theta_1+\theta_2+\theta_3)-y \end{cases} {f1(θ1,θ2,θ3)=L1cosθ1+L2cos(θ1+θ2)+L3cos(θ1+θ2+θ3)−xf2(θ1,θ2,θ3)=L1sinθ1+L2sin(θ1+θ2)+L3sin(θ1+θ2+θ3)−y -
构造雅可比矩阵
[ ∂ f 1 ∂ θ 1 ∂ f 1 ∂ θ 2 ∂ f 1 ∂ θ 3 ∂ f 2 ∂ θ 1 ∂ f 2 ∂ θ 2 ∂ f 2 ∂ θ 3 ] = [ J 1 , 1 − L 2 s i n ( θ 1 + θ 2 ) − L 3 s i n ( θ 1 + θ 2 + θ 3 ) − L 3 s i n ( θ 1 + θ 2 + θ 3 ) J 2 , 1 L 2 c o s ( θ 1 + θ 2 ) + L 3 c o s ( θ 1 + θ 2 + θ 3 ) L 3 c o s ( θ 1 + θ 2 + θ 3 ) ] 其 中 J 1 , 1 = − L 1 s i n ( θ 1 ) − L 2 s i n ( θ 1 + θ 2 ) − L 3 s i n ( θ 1 + θ 2 + θ 3 ) J 2 , 1 = L 1 c o s ( θ 1 ) + L 2 c o s ( θ 1 + θ 2 ) + L 3 c o s ( θ 1 + θ 2 + θ 3 ) \left[\begin{matrix} \frac{\partial f_1}{\partial \theta_1} & \frac{\partial f_1}{\partial \theta_2} & \frac{\partial f_1}{\partial \theta_3} \\ \frac{\partial f_2}{\partial \theta_1} & \frac{\partial f_2}{\partial \theta_2} & \frac{\partial f_2}{\partial \theta_3} \end{matrix}\right]= \left[\begin{matrix} J_{1,1} & -L_2sin(\theta_1+\theta_2)-L_3sin(\theta_1+\theta_2+\theta_3) & -L_3sin(\theta_1+\theta_2+\theta_3) \\ J_{2,1} & L_2cos(\theta_1+\theta_2)+L_3cos(\theta_1+\theta_2+\theta_3) & L_3cos(\theta_1+\theta_2+\theta_3) \end{matrix}\right]\\ 其中 J_{1,1}=-L_1sin(\theta_1)-L_2sin(\theta_1+\theta_2)-L_3sin(\theta_1+\theta_2+\theta_3)\\ J_{2,1}=L_1cos(\theta_1)+L_2cos(\theta_1+\theta_2)+L_3cos(\theta_1+\theta_2+\theta_3) [∂θ1∂f1∂θ1∂f2∂θ2∂f1∂θ2∂f2∂θ3∂f1∂θ3∂f2]=[J1,1J2,1−L2sin(θ1+θ2)−L3sin(θ1+θ2+θ3)L2cos(θ1+θ2)+L3cos(θ1+θ2+θ3)−L3sin(θ1+θ2+θ3)L3cos(θ1+θ2+θ3)]其中J1,1=−L1sin(θ1)−L2sin(θ1+θ2)−L3sin(θ1+θ2+θ3)J2,1=L1cos(θ1)+L2cos(θ1+θ2)+L3cos(θ1+θ2+θ3) -
迭代
( θ 1 n + 1 θ 2 n + 1 θ 3 n + 1 ) = ( θ 1 n θ 2 n θ 3 n ) − J − 1 ( f 1 ( θ 1 n , θ 2 n , θ 3 n ) f 2 ( θ 1 n , θ 2 n , θ 3 n ) ) \left(\begin{matrix} \theta_1^{n+1}\\ \theta_2^{n+1}\\ \theta_3^{n+1} \end{matrix}\right)= \left(\begin{matrix} \theta_1^{n}\\ \theta_2^{n}\\ \theta_3^{n} \end{matrix}\right)-J^{-1} \left(\begin{matrix} f_1(\theta_1^n, \theta_2^n,\theta_3^n)\\ f_2(\theta_1^n, \theta_2^n,\theta_3^n) \end{matrix}\right) ⎝⎛θ1n+1θ2n+1θ3n+1⎠⎞=⎝⎛θ1nθ2nθ3n⎠⎞−J−1(f1(θ1n,θ2n,θ3n)f2(θ1n,θ2n,θ3n))
这里求的是J的广义逆矩阵 J + J^+ J+
- 迭代停止条件:若 n > n m a x n>n_{max} n>nmax或方程组值变化 < ε <\varepsilon <ε则停止,返回KaTeX parse error: No such environment: at position 7: \begin{̲}̲
基于层次建模的数据结构
将角色分解成若干个关节链结构,并形成骨架树
过程
- 人体骨骼抽象成关节和链杆组成的模型
- 取某个关节点为根节点,建立骨架树
- 通过关节链的正向运动学和逆向运动学求解骨架树的正向和逆向运动
研究方向
-
骨架与角色模型绑定
-
中性姿态或静止姿态
问题:某些点属于多个部分,如何实现多个部分共同影响一个点
分离导致了变化不自然 -
顶点混合
关节处用柔性部分连接
柔性部分的一部分顶点有前关联部分的矩阵变化所得,另一部分由后关联部分的矩阵来变换
一个顶点由几个不同的矩阵加权变换 -
基于样本的权重确定
-
骨架与三维角色模型的自动绑定