c# - Ragdoll joint angle constraints -
i doing c# project on ragdolls based on thomas jakobsen's article http://www.gpgstudy.com/gpgiki/gdc%202001%3a%20advanced%20character%20physics
i have converted logic 2d , seems working having problems implementing angle constraints.
this code using @ moment:
public static void satisfyangleconstraint(particle p1, particle p, float minangle, float maxangle) { float a1 = (float)math.atan2(p1.m_x.x - p1.getfixpoint().x, p1.m_x.y - p1.getfixpoint().y); float a2 = (float)math.atan2(p.m_x.x - p.getfixpoint().x, p.m_x.y - p.getfixpoint().y); float diffangle = a2 - a1; game.currentgame.window.title = "a " + diffangle; //vector2 oldposition = p.m_x; if (diffangle > maxangle) p.m_x = rotatepoint(p.m_x, p.getfixpoint(), (diffangle - maxangle)); else if (diffangle < minangle) p.m_x = rotatepoint(p.m_x, p.getfixpoint(), (diffangle - minangle)); //p.m_oldx += p.m_x - oldposition; }
particles p1 , p joints , getfixpoint() returns position of parent joint. rotatepoint(point, centerpoint, anglerad) returns position of point rotated around centerpoint anglerad radians.
this code causes severe jitters , due fact use verlet integration - have tried compensate adding transformation old position , seem solve of problems still experience severe jitters , random force application leads me believe math bad.
i applying constraint after distance constraint because distance between joints should constant when rotating around parent joint.
this first stackoverflow question please tell me if form bad.
i found root of problem in way calculated angles between vectors nice solution problem can found here: https://stackoverflow.com/a/21486462/2342801
using method calculate a1 , a2 gets rid of jitters - problem whole approach verlet linear force application conflicted joint want force transferred rotation parent joint (inverse kinematics)
i therefore recommend different approach 2d rag dolls angle constraints.
Comments
Post a Comment