In this note, we are focusing on two new features in our C3D Solver 2022 constraints module, and demonstrate how to use them with code fragments. The constraint manager includes two- and three-dimensional solvers that allow you to impose a variety of constraints on bodies in both 2D and 3D space.
New in 2D Solver: Equidistant Curves
The primary new feature in our 2D constraint manager is offset (equidistant) curves. Offset curves are useful in a variety of areas, such as building equidistant contours for CNC milling machine paths. In our solver, offset curves are represented by a set of points located at a set distance “d” from the base curve.
The 2D solver supports the following types of constraints for this new type of curve:
- Fix an equidistant curve
- Incidence of a point and an equidistant curve
- Distance from an equidistant curve to a point, straight line, segment, circle, and another equidistant curve
All constraints for linear objects are also available for offset curves when they are based on linear curves -- parallel, perpendicular, horizontal, vertical, and angular constraints.
We implemented several new C3D Solver API methods for working with the new curves. One of the new methods registers the equidistant with the solver, taking as parameters its base curve and the value of the offset:
Another new function allows you to fix the offset of a curve, because by default its value can change:
With another new method, you can equate the offsets of two different equidistants:
The code fragment below (in C++) demonstrates how to create and add equidistant curves for a linear segment and its points:
3D Solver: Interval dimensions
Previously, we provided a C# interface for only the 2D solver; we now supply it for the 3D solver as well.
Among the new methods of the 3D solver, one is a distance interval function (the Range constraint). This constraint represents a dimension in which the value varies at specific interval. It can be imposed between two bodies, or between two parts of the same body.
An important feature of the interval constraint is that the range of acceptable values coincides with the driving dimensions. This lets you switch smoothly between intervals and related driving dimensions. In addition, intervals can be imposed between all types of objects for which similar driving dimensions are applicable.
You can use the new function through the extended solver API. The pre-existing function GCM_constraint GCM_AddDistance(...) adds a driving dimension; its fourth parameter was changed:
The above code fragment demonstrates the addition of an interval dimension to a new function, where the fourth parameter GCM_interval represents a structure that stores the values of the interval boundaries.
The code fragment (C++) below demonstrates how to create and add an interval dimension between two bodies:
In the future, we plan to add an interval constraint for angular dimensions. After that, we plan to add both groups of interval constraints to the 2D solver.