A closure algorithm for a class of closed kinematic chains