Algorithm for computing the connectivity in planar kinematic chains and its application