Previous section-----Next section

5.1.1 StageSwitch

A multistage mechanism constraint-switching function.

A StageSwitch constraint returns an error if any of the test expressions fail to return either True or False at runtime. Because StageSwitch does evaluate its own arguments immediately, unlike Which or If, test expressions such as SameQ should not be used. This is because SameQ evaluates immediately to True or False instead of waiting until some future condition changes. Also, a StageSwitch constraint is invalid if all of the test expressions return False at runtime because no constraint is applied to the model.
Each of the constraints supplied to the StageSwitch constraint are standard Mech constraint objects or lists of constraint objects. Each constraint or list of constraints must constrain the same number of degrees of freedom. Note that the constraint numbers of the constraints that are inside of the StageSwitch constraint are irrelevant. The constraint number of the entire StageSwitch constraint is the only one that is used to reference the constraint.

Examples

This loads the Modeler2D package.

The following example shows how StageSwitch (constraint 1) might be used to model a pin on a slider that slides in one of two straight tracks on the ground body. Which track to use is determined by the value of the user-defined symbol whichtrack, which must be either 1 or 2.

Here is a valid StageSwitch constraint.

The following example shows how a StageSwitch constraint that constrains two degrees of freedom might be implemented. The first constraint in the StageSwitch constraint forces the origin of the slider to be coincident with the origin of the ground. If the value of the user-defined symbol pressure rises above 100 units, the second constraint pair becomes active and forces the origin of the slider to lie upon a line and be positioned as a function of the value of pressure.

Here is a valid StageSwitch constraint.