4

使用 CCDIK 或 FABRIK 实现逆向动力学

 1 year ago
source link: https://www.yunyoujun.cn/posts/methods-for-inverse-kinematics/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

动力学主要分为正向动力学(FK)和反向动力学(IK)。 正向动力学实现起来十分简单,了解点基本原理,或者网上一搜,都能写出来。

反向动力学中比较流行的方法则是:

还有几何分析与雅可比矩阵的方法,计算起来比较复杂,用的不是太多。

维基百科和一些论文、博客也讲得很清楚了。 (摔,那你水这篇文章干什么?) 为了大家更方便地从代码层级来理解,这篇文章最主要的作用大概就是提供 Demo 了。

下面主要分为 CCDIK 和 FABRIK 两种方法来说。

CCDIK #

CCD - p5.js #

Fullscreen: https://editor.p5js.org/YunYouJun/full/kJJqXPATQ Editor: https://editor.p5js.org/YunYouJun/sketches/kJJqXPATQ

代码参考自:Simple Inverse Kinematics - Dave Pagurek

FABRIK #

FABRIK 是一种启发式算法。实现起来较为简单,计算又少又快。

原文的算法出自这篇论文 FABRIK: A fast, iterative solver for the Inverse Kinematics problem

算法的大致描述看这里也可以理解,就不再多述。

FABRIK - p5.js #

Fullscreen: https://editor.p5js.org/YunYouJun/embed/bS8jB3EsC Editor: https://editor.p5js.org/YunYouJun/sketches/bS8jB3EsC

代码参考自:Inverse Kinematics - Fixed Point - Coding Challenge #64.3 · The Coding Train

Cocos Creator #

新年 🧨 版(小 bug 之后修)

cocos-creator-ik

GitHub: https://github.com/YunYouJun/cocos-creator-ik/

两者对比 #

CCDIK 实现较为简单,FABRIK 则相比 CCDIK 效率更高,但与 FABRIK 不同,CCDIK 提供了定义角约束的功能,需要在解算中限制任意骨骼的旋转时较为实用。

其他参考链接 #


To Be Continued.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK