关于关节角度约束的最佳逆运动学算法

时间:2014-01-27 04:27:09

标签: inverse-kinematics

我为反向运动学实现了CCD算法,它工作得很好,但它有约束失败,我想实现一个系统,如果手臂无法到达目标,它会试图接近它。

我试图将约束放在CCD算法中,也就是说,如果我的旋转角度高于或低于约束,我将其限制为最大值或最小值。例如,如果旋转角度是100度并且约束是90,那么我旋转90并且基于我计算其他角度,它适用于某些情况但是对于大多数情况都失败。

有人告诉我一个3D IK算法来处理约束吗?

1 个答案:

答案 0 :(得分:3)

CCD本身就像魅力一样。 如果您正在处理3D,请首先找到您应该在每个轴上执行的旋转,而不应用骨骼限制。

之后,方法

expectedRotation.X = min(expectedRotation.X, maxLimit.X)
expectedRotation.X = max(expectedRotation.X, minLimit.X)
expectedRotation.Y = min(expectedRotation.Y, maxLimit.Y)
expectedRotation.Y = max(expectedRotation.Y, minLimit.Y)
expectedRotation.Z = min(expectedRotation.Z, maxLimit.Z)
expectedRotation.Z = max(expectedRotation.Z, minLimit.Z)

错误。因为,如果你不能进一步移动其中一个轴,另外两个轴将继续移动,你会得到奇怪的结果。

修复:

如果3个轴中的任何一个与限制约束不匹配,则根本不能更改旋转。

首先将所有角度转换为-180到180格式的度数。然后以下将做

vector3df angleDifference = expectedRotation - baseRotation; //baseRotation is just the initial rotation from which the bone limits are calculated.

if(angleDifference.X < boneLimits.minRotation.X || angleDifference.Y < boneLimits.minRotation.Y || angleDifference.Z < boneLimits.minRotation.Z || angleDifference.X > boneLimits.maxRotation.X || angleDifference.Y > boneLimits.maxRotation.Y || angleDifference.Z > boneLimits.maxRotation.Z)
    return currentRotation;

return expectedRotation;
相关问题