[Update: Scroll the update at the end to see new information about all of this]

When I first wrote the Linkage software, I knew that if you rotate some points, that they can’t be rotated back to their original positions because of math and rounding issues. I immediately knew that I wanted to mitigate this problem by keeping track of an original point and a temporary point of rotation. I also knew that I needed some sort of temporary point for when the mechanism is simulating so that it’s original structure is not lost during the simulation. This last issue was important since the simulation always calculates the position of all of the links, connectors, etc, from their original locations. To be blunt, I overdid it. I created three different points for connectors: the original, the temporary edit point, and the simulation point. Actually, I’m not sure if that’s how they are used. What I do know is that with the curves that I’m adding, I only keep track of two points: the original, and the point for editing and simulation. The original is always used as the starting point and the temporary point just called the “point”, is used for anything transient. Note that “point” means a coordinate in 2D space.

I’m thinking of rewriting the entire location management code to only have two points for all elements that have locations (links have no location, just a list of connectors that themselves have locations). But I won’t do it. rewriting is only really meaningful if I do it while making changes or adding features and right now, I’m not doing that to the connector code.

The curve handling is coming along rather well. I have almost all of the data structures created and working. The curves are actually polycurves with nodes and segments. Each segment can be a line or a Bezier curve and arcs are planned but not implemented. I can drop in a curve with three segments (the default) and then set the line size and color. I can make it a closed-loop or open, and it can be rotated, stretched, moved, copied, and pasted. Polycurves can be selected by dragging a selection box around them and I’m working now on being able to detect clicks on the curve itself; The math is fairly easy but being accurate means iterating and interpolating computations that need to be as efficient as possible. Well, they don’t really need to be efficient since a delay of a few milliseconds when selecting elements is not a problem. But that time goes up a bit for every curve in the mechanism and I want to make sure that a very curvy mechanism doesn’t cause slowdowns during editing.

After I get the curve selection code working, I will be working on the curve editor. This will be the hardest part because I need to make the nodes and control points of the curves all moveable. There also needs to be a way to add nodes anywhere and a way to delete them. I even want to be able to snap the nodes and control points when moving them, as well as let them be aligned with the align menu features – aligning a few nodes to a connector, or vice-versa – is a very important feature to me.

Then what? I don’t have a list. Anything that can be done with a connector should be available with one or mode curve nodes selected. The final issue to resolve is when and how to make the nodes editable. I don’t want them to be selectable unless the curve has already been selected. Do I just allow their selection at that time like I do with the actuator throw “knob” and the circle radius control “knob”? Or is a new tool needed? I hate tool modes. I hate any action that requires a mode change before the action. A keypress might be the way to go (and a button to match), or maybe I just change things so when an element is selected and clicked two times more (one time changes to rotation mode), the nodes all become editable. I might have to try all of these and see which one feels the best. Or I can get user feedback. I’m not sure yet.

I might make an Alpha test app available to anyone who wants to see the curve feature in progress. There’s no meaningful way to use it so far, the shape can’t be changed, but it still might be interesting for some people to see.


I figured it out! The simulator needs to move connectors around during simulation and if there is a failure, not show some connectors in their new locations and some in their old locations. That’s why connectors have three different points (locations/positions) associated with them. Now I’m pretty sure that I used the wrong names for the functions used to manipulate the new curve control points. I’ll have to revisit the whole thing and make some name changes for sure.