A method to simulate the interactions between objects of a mechanism is described. The method can simulate planar kinematic chains of any length. The same method is used with modifications to generate the geometry of one object of a kinematic pair given the required functional relationship and the geometry of the other object. The planar contour shape of each object of a kinematic pair is represented as an arrangement of very small entities called molecules. Given the motion of the driver, the motion of the other object of the pair, known as the driven, is determined by global constraints and the prevention of geometric interference among the molecules of both members. The molecular representation allows very detailed changes in the shapes of the members. This facilitates automatic optimal shape design and very generalized kinematic analysis and synthesis. A computer implementation, intended to be used in the future with higher-level intelligent processing, is described and examples are provided.