This paper presents a single, unified, and efficient algorithm for animating the coupler motions of all four-bar mechanisms formed with revolute (R) and prismatic (P) joints. This is achieved without having to formulate and solve the loop closure equation for each type of four-bar linkages separately. Recently, we developed a unified algorithm for synthesizing various four-bar linkages by mapping planar displacements from Cartesian space to the image space using planar quaternions. Given a set of image points that represent planar displacements, the problem of synthesizing a planar four-bar linkage is reduced to finding a pencil of generalized manifolds (or G-manifolds) that best fit the image points in the least squares sense. In this paper, we show that the same unified formulation for linkage synthesis leads to a unified algorithm for linkage analysis and simulation as well. Both the unified synthesis and analysis algorithms have been implemented on Apple's iOS platform.