Advertisement Jump to content
Sign in to follow this  
manu1001

help with CCD algorithm

This topic is 3552 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i'm trying to achieve inverse kinematics using cyclic-coordinate descent (CCD) for a chain of joints - (0, 1, 2, ... , s). from what i've understood of it, i've written some code which does not work at all. could you please tell where i'm going wrong. i've modified the code to make it understandable.
//                  * d (x,y)
//                 
//                
//  *-----*------*-------*
//        <---(i) q    (s) p

Coord p, q, d;
Joint *ptrp, *ptrq, *ptrj;
double m1, m2, t;

// 's + 1' number of joints in chain

d = target_coord();

ptrp = getjoint(s);
for (i = s - 1; i > 0; i--){

	p = ptrp->getcoord();
	
        ptrq = getjoint(i);
	q = ptrq->getcoord();

        // calculate angle 't' between pq and dq using slopes
	m1 = (p.y - q.y) / (double) (p.x - q.x);
	m2 = (d.y - q.y) / (double) (d.x - q.x);
	t = (m1 * m2 != -1.0)? atan((m2 - m1) / (1 + m1 * m2)) : PI / 2;

	for (j = i + 1; j <= s; j++){     // for all children
		ptrj = getjoint(j);
		ptrj->add_rotangle(t);
	}
}



the above loop will be run several times inside another loop.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!