Using the Complex Curve Component in Subassembly Studio
The Complex Curve component is a powerful but little known component in Subassembly Studio which allows you to model virtually any parametric curve with ease. The ‘curve’ doesn’t even need to actually be a curve – it could also be a randomized multi-segment link that can be used to simulate a sampled surface.
Let’s first take a look at what is required in order to model a parametric curve.
At its core, the Complex Curve component is a conditional iteration over a parametric RPN Expression. Each iteration produces another point on the curve, and at the end of each iteration a condition is checked to determine whether to continue (a ‘do-while’ loop). The result of the calculation is stored in the Calculation Result Variable (the ‘T’ variable in a parametric equation), and separate X and Y variables are also maintained (and set by the RPN calculation).
In each iteration, the RPN stack is evaluated and then the last value on the RPN stack is assigned to the Calculation Result Variable. A point is also added to the link being created at the coordinates described by the X and Y variable references; if these are configured as ‘delta’ values, the variable value is added to the corresponding coordinate of the reference point for the component, else the variables describe the distance relative to the subassembly origin at (0,0). The X (or ‘Offset’) values can also have the subassembly ‘Side’ applied automatically (multiplied by -1 for left side; 1 for right side).
Let’s look at a simple example – suppose we want to model a parabolic curve:
Y(T) = (T^2) / 25
X(T) = T
dT = 0.1
For these equations, we configure the RPN expression as follows (for a detailed discussion of how RPN calculations work, click here):
Here’s what is happening so far:
- We place the value of T onto the stack. It is initialized with a value of 0 but will change in subsequent iterations.
- We square this value, then divide by 25 and store the result in the variable Y.
- Next we reference T again and place the value onto the stack ahead of Y (which will not be used again in the calculation but is nonetheless left on the stack)
- We write the top item on the stack (equal to T) to the variable X.
- We then reference the variable dT, which is set to a value of 0.1.
- We add the top two items on the stack (T and dT) and leave the sum as the top item on the stack.
Upon finishing this calculation, the top item from the stack (equal to T + dT) is written to T, thus incrementing T for the next iteration. We also at this point append a new point onto the point list which will be used to create the curve link. The variables X and Y are used as the coordinates of this point. To enable this to occur, we configure our Complex Curve component as follows:
The result is a curved link that looks like this:
Note that we have the options for X and Y to be interpreted as ‘delta’ values enabled. We also used a reference point of ‘2’ for the curve component. Point ‘2’ is conveniently located away from the origin, thus allowing us to demonstrate the effect of changing the ‘delta’ options; if we instruct the component to treat the X and Y variables as absolutes instead of delta values, the result looks like this:
Notice that the curve is now located relative to the subassembly origin.
The options for interpreting each coordinate value as a ‘delta’ are independent of one another, thus allowing one coordinate value to be a ‘delta’ while the other is ‘absolute’.
The current implementation is using a maximum number of iterations to control the stopping point (the default configuration). You can also set minimum/maximum coordinates or a custom ‘test case’. All such conditions are evaluated on each iteration and if any fails, the process is stopped and the curve is considered completed.
Most any curve can be modeled using this method – you simply need to create the proper RPN Expression.