kinematics code for AP