Research Article

Constructing Swimming Training Model Based on Cyclic Coordinate Descent Algorithm

Pseudocode 1

 //SolveIK_CCD function is used for the CCD algorithm to solve inverse kinematics problem
 Step 1: SolveIK_CCD(CJoint&FixedJoint, CBone EndBone, Position Aim_pos)
 {
 //FixedJoint Fixed the joints of the joint chain
 //EndBone End bone of the joint chain
 //Aim_pos- Desired target location
 While (To reach the specified number of iterations && the distance between the current end bone position and the target position is greater than the specified error range)
 {
 While (The fixed joint has not been rotated yet)
 {
 Step 2: The angle between the vector pointing from the current joint to the end bone and the vector pointing from the current joint to the target position;
 Step 3: Take the cross product of and to get the rotation axis vector v3 that is perpendicular to both and ;
 Step 4: The current joint rotates around the axis of the vector by an angle of ;
  The parent joint of the current joint becomes the new current joint;
 }//end while
 Step 5: Find the distance between the position of the current end bone and the target position;
 Step 6: The number of iterations is incremented by 1;
 }//end while
 Function returns;
 }//end SolveIK_CCD
 Taking the solution of the arm as an example, the shoulder joint is regarded as the fulcrum, and the palm bone is thought to be the joint chain’s final result. At this time, the fixed joint is the shoulder joint, and the end bone is the hand bone. The function call form is as follows:
 SolveIK_CCD(m_arrJoint[jLShoulder],m_arrBone[LHand],AimPos