I did some work on the linkage simulator last night. I think I’ve narrowed down the sliding connector issue in the linkage program. There are essentially three situations I need to handle. Consider these images:

Figure 1.

In figure 1, A and E are fixed. F will be moved by the simulator before the slider can be moved. B then needs to be moved to a new position based on A and F.

In case it’s not clear exactly what is going on here, A, E, and C are all connected to the ground and C is set to rotate at a given RPM while A and E can rotate freely. The circles represent connectors and the square is the sliding connector stuck between A and B.

Figure 2.

In figure 2, A is fixed in position and B becomes fixed in position first before the slider position can be determined. The slider F needs to be moved into a new position based on A and B.

Figure 3.

The above image in figure 3 is a little less obvious. It is really a piston BD moving in and out of a cylinder defined by H and I. E is not lined up with HI to make it more obvious that there are two links that act as piston and cylinder. (This makes me think that a user should be able to change the line and fill styles to somehow make this type of thing more clear).

D is moved by the simulator first and E is always fixed. H, I, and B all need to be moved to line up with each other.

I think that these three situations are the only three possible and any mechanism with sliders will resolve to these or be non-functioning.

I’ve got the editor working and I’m reworking some of the code to simplify it. There are more lines of code now but only because I added iterator functions to some of the linked lists so that I can just call the iterator with an appropriate functor and all of the looping, etc…, is handled by the iterator and the operation is handled by the functor.

I also went ahead and added momentum to the simulator. The simulator doesn’t really change a mechanism from its last state to a new state for each step in the simulation. It always starts from scratch. By starting from scratch, there are no numeric rounding issues that increase during the simulation. The only thing I did with the previous state of the mechanism is use it to decide when there are two possible locations for a connector that are both valid. The momentum is simulated by determining the next potential location for a connector based on the previous two locations. This potential new location is used to decide the actual new location when there is a choice.

It worked out well although it’s hard to draw a mechanism that is exact enough for this to matter. I’ll have to add numeric in out later so that the lengths and positions of things can be very accurately specified. then it might be more important.

This evening, I’ll be writing the slider simulation for the easy cases to see how it works and if I somehow didn’t catch some odd situation that needs special handling. i think that it should work fine.