AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Geometric Constraint Solving​​

2D Constraint Solving

Constraint Element Types

Constraint element types include: points, line segments, circles, circular arcs, ellipses, elliptical arcs, parabolic arcs, hyperbolic arcs, and B-spline curves. Below, we will introduce the creation methods for these constraint elements.

Point

// Create constraint handle
// Create a point in 2D
AMCAX::GCS::Point2d p{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint, p);
// Get point
AMCAX::GCS::Point2d point2d = gcsSystem.GetPoint2d(handlePoint);
The wrapper for GCSSystem.
Definition AMCAXGCS.h:352
Point2d GetPoint2d(const GCSWVarGeomHandle &h) const
Get point.
Status Create2dPoint(GCSWVarGeomHandle &h, const Point2d &point)
Create a point in 2D.
The wrapper for GCSVarGeomHandle.
Definition AMCAXGCS.h:268
Point in 2d.
Definition AMCAXGCS.h:127

After creation, it supports updating point:

// Update point in 2d
AMCAX::GCS::Point2d p_update{ 0., 0. };// New position for the point
AMCAX::GCS::Status status = gcsSystem.UpdatePoint2d(handlePoint, p_update);
// Get point
AMCAX::GCS::Point2d point2d_new = gcsSystem.GetPoint2d(handlePoint);
Status UpdatePoint2d(const GCSWVarGeomHandle &h, const Point2d &point)
Update point in 2d.
Status
Enumeration of GCSSystem status.
Definition AMCAXGCS.h:237

Line Segment

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 2. };
AMCAX::GCS::Point2d p2{ 3., 4. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Get line segment
AMCAX::GCS::Line2d line2d = gcsSystem.GetLine2d(handleLine);
Status Create2dLine(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &point0, const GCSWVarGeomHandle &point1)
Create a line segment in 2D.
Line2d GetLine2d(const GCSWVarGeomHandle &h) const
Get line.
Line in 2d.
Definition AMCAXGCS.h:143

Circle

Circles are defined by the following core parameters:

  • Center (center): c
  • Radius (radius): r
// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
// Create a circle in 2D
double radius = 2.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter, radius);
// Get circle
AMCAX::GCS::Circle2d circle2d = gcsSystem.GetCircle2d(handleCircle);
Circle2d GetCircle2d(const GCSWVarGeomHandle &h) const
Get circle.
Status Create2dCircle(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &center, double radius)
Create a circle in 2D.
Circle in 2d.
Definition AMCAXGCS.h:153

After creation, it supports updating circle:

// Update circle in 2d
AMCAX::GCS::Point2d center_update{ 1., 1. };// New position for the center
double radius_update = 3.0;// New radius
AMCAX::GCS::Status status = gcsSystem.UpdateCircle2d(handleCircle, center_update, radius_update);
// Get circle
AMCAX::GCS::Circle2d circle2d_update = gcsSystem.GetCircle2d(handleCircle);
Status UpdateCircle2d(const GCSWVarGeomHandle &h, const Point2d &center, double radius)
Update circle in 2d.

Circular Arc

To represent the range of a circular arc, two parameters are introduced:

  • Start angle (thetaStart): Position of the arc's starting point in the circle's parametric representation
  • Angle range (thetaRange): Range of the arc in the circle's parametric representation

If thetaRange > 0, the arc is counterclockwise, θ∈[thetaStart, thetaStart + thetaRange]; if thetaRange < 0, the arc is clockwise, θ∈[thetaStart + thetaRange, thetaStart].

The coordinates of any point P on the arc can be obtained through polar coordinate conversion:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArc, handleArcstart, handleArcend, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d start{ 2., 0. };
AMCAX::GCS::Point2d end{ -2., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcstart, start);
gcsSystem.Create2dPoint(handleArcend, end);
// Create an arc in 2D
gcsSystem.Create2dArc(handleArc, handleCenter, handleArcstart, handleArcend, range);
// Get arc of circle
AMCAX::GCS::Arc2d arc2d = gcsSystem.GetArc2d(handleArc);
Status Create2dArc(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &center, const GCSWVarGeomHandle &start, const GCSWVarGeomHandle &end, double range=0)
Create an arc in 2D.
Arc2d GetArc2d(const GCSWVarGeomHandle &h) const
Get arc.
constexpr double half_pi
pi/2
Definition Constants.hpp:50
Arc of circle in 2d.
Definition AMCAXGCS.h:161

Note: When creating an arc, the parameter range specifies the arc's extent. If not specified, range defaults to 0, and the solver will calculate the range in a counterclockwise direction.

Ellipse

Ellipses are defined by the following core parameters:

  • Center (center): c
  • Major axis (majorAxis)
  • Minor axis (minorAxis)
  • Major radius (majorRadius)
  • Minor radius (minorRadius)
// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleEllipse, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius);
// Get ellipse
AMCAX::GCS::Ellipse2d ellipse2d = gcsSystem.GetEllipse2d(handleEllipse);
Ellipse2d GetEllipse2d(const GCSWVarGeomHandle &h) const
Get ellipse.
Status Create2dEllipse(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &center, const Vector2d &majorAxis, double majorRadius, const Vector2d &minorAxis, double minorRadius)
Create an ellipse in 2D.
Ellipse in 2d.
Definition AMCAXGCS.h:171
Vector in 2d.
Definition AMCAXGCS.h:135

After creation, it supports updating ellipse:

// Update ellipse in 2d
AMCAX::GCS::Point2d center_update{ 1., 1. };// New position for the center
AMCAX::GCS::Vector2d majorAxis_update{ 0.,1. };// New direction for the major axis
double majorRadius_update = 3.0;// New major radius
double minorRadius_update = 2.0;// New minor radius
AMCAX::GCS::Status status = gcsSystem.UpdateEllipse2d(handleEllipse, center_update, majorAxis_update, majorRadius_update, minorRadius_update);
// Get ellipse
AMCAX::GCS::Ellipse2d ellipse2d_update = gcsSystem.GetEllipse2d(handleEllipse);
Status UpdateEllipse2d(const GCSWVarGeomHandle &h, const Point2d &center, const Vector2d &majorAxis, double major, double minor)
Update ellipse in 2d.

Elliptical Arc

To represent the range of an elliptical arc, two parameters are introduced:

  • Start angle (thetaStart): Position of the elliptical arc's starting point in the circle's parametric representation
  • Angle range (thetaRange): Range of the elliptical arc in the circle's parametric representation

If thetaRange > 0, the elliptical arc is counterclockwise, θ∈[thetaStart, thetaStart + thetaRange]; if thetaRange < 0, the elliptical arc is clockwise, θ∈[thetaStart + thetaRange, thetaStart].

The coordinates of any point P on the elliptical arc can be obtained through polar coordinate conversion:

  • Calculate the major axis angle α (angle between major axis and x-axis)

α = atan2(majorAxis.y, majorAxis.x)

  • Calculate coordinates
// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArcOfEllipse, handleArcOfEllipsestart, handleArcOfEllipseend, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d start{ 2., 0. };
AMCAX::GCS::Point2d end{ -2., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcOfEllipsestart, start);
gcsSystem.Create2dPoint(handleArcOfEllipseend, end);
// Create an arc of ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dArcOfEllipse(handleArcOfEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius, handleArcOfEllipsestart, handleArcOfEllipseend, range);
// Get arc of ellipse
AMCAX::GCS::ArcOfEllipse2d ellipse_acr2d = gcsSystem.GetArcOfEllipse2d(handleArcOfEllipse);
ArcOfEllipse2d GetArcOfEllipse2d(const GCSWVarGeomHandle &h) const
Get arc of ellipse.
Status Create2dArcOfEllipse(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &center, const Vector2d &majorAxis, double majorRadius, const Vector2d &minorAxis, double minorRadius, const GCSWVarGeomHandle &start, const GCSWVarGeomHandle &end, double range=0)
Create an arc of ellipse in 2D.
Arc of ellipse in 2d.
Definition AMCAXGCS.h:182

Note: When creating an elliptical arc, the parameter range specifies the arc's extent. If not specified, range defaults to 0, and the solver will calculate the range in a counterclockwise direction.

Parabolic Arc

Parabolic arcs are defined by the following core parameters:

  • Focus (focus): f
  • Vertex (vertex): v
  • paramStart: Vertical coordinate of the arc's starting point in the parabola's local coordinate system
  • paramEnd: Vertical coordinate of the arc's ending point in the parabola's local coordinate system
// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArcOfParabola, handleArcOfParabolafocus, handleArcOfParabolavertex, handleArcOfParabolastart, handleArcOfParabolaend;
// Create a point in 2D
AMCAX::GCS::Point2d focus{ 1., 0. };
AMCAX::GCS::Point2d vertex{ 0., 0. };
AMCAX::GCS::Point2d start{ 1., 2. };
AMCAX::GCS::Point2d end{ 1., -2. };
gcsSystem.Create2dPoint(handleArcOfParabolafocus, focus);
gcsSystem.Create2dPoint(handleArcOfParabolavertex, vertex);
gcsSystem.Create2dPoint(handleArcOfParabolastart, start);
gcsSystem.Create2dPoint(handleArcOfParabolaend, end);
// Create an arc of parabola
gcsSystem.Create2dArcOfParabola(handleArcOfParabola, handleArcOfParabolafocus, vertex, handleArcOfParabolastart, handleArcOfParabolaend);
// Get arc of parabola
AMCAX::GCS::ArcOfParabola2d parabola_arc2d = gcsSystem.GetArcOfParabola2d(handleArcOfParabola);
Status Create2dArcOfParabola(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &focus, const Point2d &vertex, const GCSWVarGeomHandle &start, const GCSWVarGeomHandle &end)
Create an arc of parabola in 2D.
ArcOfParabola2d GetArcOfParabola2d(const GCSWVarGeomHandle &h) const
Get arc of parabola.
Arc of parabola in 2d.
Definition AMCAXGCS.h:195

After creation, it supports updating parabolic arc:

// Update parabola in 2d
AMCAX::GCS::Point2d vertex_update{ -1., 0. };// New position for the vertex
AMCAX::GCS::Point2d focus_update{ 0., 1. };// New position for the focus
AMCAX::GCS::Status status = gcsSystem.UpdateParabola2d(handleArcOfParabola, vertex_update, focus_update);
// Get arc of parabola
AMCAX::GCS::ArcOfParabola2d parabola_update = gcsSystem.GetArcOfParabola2d(handleArcOfParabola);
Status UpdateParabola2d(const GCSWVarGeomHandle &h, const Point2d &vertex, const Point2d &focus)
Update parabola in 2d.

Hyperbolic Arc

Hyperbolic arcs are defined by the following core parameters:

  • Focus (focus)
  • Hyperbola center (center)
  • Major radius (majorRadius)
  • paramStart: Vertical coordinate of the arc's starting point in the hyperbola's local coordinate system
  • paramEnd: Vertical coordinate of the arc's ending point in the hyperbola's local coordinate system
// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArcOfHyperbola, handleArcOfHyperbolaCenter, handleArcOfHyperbolaFocus, handleArcOfHyperbolaStart, handleArcOfHyperbolaEnd;
// Create a point in 2D
AMCAX::GCS::Point2d focus{ 2., 0. };
AMCAX::GCS::Point2d start{ 2., 3. };
AMCAX::GCS::Point2d end{ 2., -3. };
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handleArcOfHyperbolaFocus, focus);
gcsSystem.Create2dPoint(handleArcOfHyperbolaStart, start);
gcsSystem.Create2dPoint(handleArcOfHyperbolaEnd, end);
gcsSystem.Create2dPoint(handleArcOfHyperbolaCenter, center);
// Create an arc of hyperbola
double majorRadius = 1.0;
gcsSystem.Create2dArcOfHyperbola(handleArcOfHyperbola, handleArcOfHyperbolaCenter, handleArcOfHyperbolaFocus, majorRadius, handleArcOfHyperbolaStart, handleArcOfHyperbolaEnd);
// Get arc of hyperbola
AMCAX::GCS::ArcOfHyperbola2d hyperbola_arc2d = gcsSystem.GetArcOfHyperbola2d(handleArcOfHyperbola);
Status Create2dArcOfHyperbola(GCSWVarGeomHandle &h, const GCSWVarGeomHandle &center, const GCSWVarGeomHandle &focus, double majorRadius, const GCSWVarGeomHandle &start, const GCSWVarGeomHandle &end)
Create an arc of hyperbola in 2D.
ArcOfHyperbola2d GetArcOfHyperbola2d(const GCSWVarGeomHandle &h) const
Get arc of hyperbola.
Arc of hyperbola in 2d.
Definition AMCAXGCS.h:205

After creation, it supports updating hyperbolic arc:

// Update hyperbola in 2d
AMCAX::GCS::Point2d center_update{ 1., 0. };// New position for the hyperbola
AMCAX::GCS::Point2d focus_update{ 4., 0. };// New position for the focus
double majorRadius_update = 2.0;// New major radius
AMCAX::GCS::Status status = gcsSystem.UpdateHyperbola2d(handleArcOfHyperbola, center_update, focus_update, majorRadius_update);
// Get arc of hyperbola
AMCAX::GCS::ArcOfHyperbola2d hyperbola_update = gcsSystem.GetArcOfHyperbola2d(handleArcOfHyperbola);
Status UpdateHyperbola2d(const GCSWVarGeomHandle &h, const Point2d &center, const Point2d &focus, double major)
Update hyperbola in 2d.

B-Spline Curve

To construct a non-periodic B-spline curve, you can use Create2dBSplineCurve.

Non-Rational

// Create constraint handle
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints;
std::vector<AMCAX::GCS::Point2d> controlPoints{
{0.5, 0.5},
{1.0, 3.0},
{3.0, 1.0},
{3.8,2.0},
{2.5,3.5},
{1.0,0.5},
{0.3,2.0} };
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
// Create a non-rational B-spline curve in 2D
int degree = 5;
std::vector<double> knotSequence{ 0.,0., 0.25, 0.5,0.75,1.,1.25,1.5,2.,2. ,2.,2.,2. };
gcsSystem.Create2dBSplineCurve(handleBspline, handleControlPoints, knotSequence, degree);
// Get b-spline curve
AMCAX::GCS::BSplineCurve2d bspline2d = gcsSystem.GetBSplineCurve2d(handleBspline);
Status Create2dBSplineCurve(GCSWVarGeomHandle &h, const std::vector< GCSWVarGeomHandle > &controlPoints, const std::vector< double > &knotSequence, int degree)
Create a non-rational B-spline curve in 2D.
BSplineCurve2d GetBSplineCurve2d(const GCSWVarGeomHandle &h) const
Get b-spline curve.
B-spline curve in 2d.
Definition AMCAXGCS.h:216

To construct a non-periodic, non-rational B-spline curve with a fixed degree of 3, you can use Create2dCubicBSplineCurve.

// Create constraint handle
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints;
std::vector<AMCAX::GCS::Point2d> controlPoints{
{0.,0.},
{1.,1.},
{2.,2.},
{3.,-5.},
{0.,0.} };
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
// Create a non-rational cubic B-spline curve in 2D
std::vector<double> knotSequence{ 0.,0., 0.25, 0.5,0.75,1.,1.,1.,1. };
gcsSystem.Create2dCubicBSplineCurve(handleBspline, handleControlPoints, knotSequence);
// Get b-spline curve
AMCAX::GCS::BSplineCurve2d bspine2d = gcsSystem.GetBSplineCurve2d(handleBspline);
Status Create2dCubicBSplineCurve(GCSWVarGeomHandle &h, const std::vector< GCSWVarGeomHandle > &controlPoints, const std::vector< double > &knotSequence)
Create a non-rational cubic B-spline curve in 2D.

Rational

// Create constraint handle
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints;
std::vector<AMCAX::GCS::Point2d> controlPoints{
{0., 0.},
{1., 1.},
{2., 2.},
{3.,-5.} };
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
// Create a rational B-spline curve in 2D
std::vector<double> weights = { 1., 2., 1., 1. };
std::vector<double> knots = { 1., 2., 3., 4. };
std::vector<int> multiplicities = { 2, 2, 2, 2 };
int degree = 3;
AMCAX::GCS::Status status=gcsSystem.Create2dBSplineCurve(handleBspline, handleControlPoints, weights, knots, multiplicities, degree);
// Get b-spline curve
AMCAX::GCS::BSplineCurve2d bspline2d = gcsSystem.GetBSplineCurve2d(handleBspline);

Note: Regardless of the construction method, the following B-spline characteristics must be satisfied:

  • 1.Satisfy m = n + p + 1 and p ≥ n + 1 (where m is the number of knot vectors, n is the curve degree, and p is the number of control points)
  • 2.Knot vectors must be non-decreasing
  • 3.The repetition count of the first and last knot vectors must not exceed n + 1, and the repetition count of intermediate knot vectors must not exceed n

Update

The UpdateBSpline2d function enables the update of core parameters of a B-spline curve (including control points, knot vectors, knot multiplicities, and curve degree), and also supports the update of weight parameters. Specific usage examples are as follows:

Basic Parameter Update (Without Weights)
// Create constraint handle
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints, handleControlPoints_update;
// Create a B-spline curve in 2D
int degree = 1;
std::vector<AMCAX::GCS::Point2d> controlPoints{
{1.13, 4.1},
{1.63, 4.8},
{2.13, 5.2},
{2.63, 5.0} };
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
std::vector<double> flatKnots;
for (int i = 0; i < controlPoints.size() + degree + 1; i++)
{
flatKnots.push_back(i);
}
gcsSystem.Create2dBSplineCurve(handleBspline, handleControlPoints, flatKnots, degree);
// Update bspline curve in 2d
std::vector<AMCAX::GCS::Point2d> controlPoints_update
{
{1.,12.},
{2.,2.431},
{1.3421,5.123},
{2.432153,12.432},
{4.3421,1.321},
{3.123,83.10},
{1.0546,1.112},
{1.65,8.130},
{8.23,53.01},
{15,2.13}
};
for (AMCAX::GCS::Point2d& point_update : controlPoints_update) {
AMCAX::GCS::GCSWVarGeomHandle handlePoint_update;
gcsSystem.Create2dPoint(handlePoint_update, point_update);
handleControlPoints_update.push_back(handlePoint_update);
}
int degree_update = 2;
std::vector<double> flatKnots_update;
std::vector<int> multiplicities_update;
for (int i = 0; i < controlPoints_update.size() + degree_update + 1; i++) {
flatKnots_update.push_back(i);
multiplicities_update.push_back(1);
}
AMCAX::GCS::Status status = gcsSystem.UpdateBSpline2d(handleBspline, handleControlPoints_update, flatKnots_update, multiplicities_update, degree_update);
// Get the update b-spline curve
AMCAX::GCS::BSplineCurve2d bspline2d_update = gcsSystem.GetBSplineCurve2d(handleBspline);
Status UpdateBSpline2d(GCSWVarGeomHandle &h, const std::vector< GCSWVarGeomHandle > &controlPoints, const std::vector< double > &knots, const std::vector< int > &multiplicities, int degree)
Update bspline curve in 2d.
Parameter Update with Weights
// Create constraint handle
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints, handleControlPoints_update;
// Create a B-spline curve in 2D
std::vector<AMCAX::GCS::Point2d> controlPoints{
{1.13, 4.1},
{1.63, 4.8},
{2.13, 5.2},
{2.63, 5.0},
{3.13, 4.3},
{3.63, 3.9},
{4.13, 4.2},
{4.63, 4.9},
{5.13, 5.4},
{5.63, 5.1}
};
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
std::vector<double> weights = { 1.0, 1.5, 0.8, 1.2, 0.9, 1.1, 1.3, 0.7, 1.4, 1.0 };
int degree = 3;
std::vector<double> flatKnots;
std::vector<int> multiplicities;
for (int i = 0; i < controlPoints.size() + degree + 1; i++) {
flatKnots.push_back(i);
multiplicities.push_back(1);
}
gcsSystem.Create2dBSplineCurve(handleBspline, handleControlPoints, flatKnots, degree);
// Update bspline curve in 2d
std::vector<AMCAX::GCS::Point2d> controlPoints_update
{
{0.0, 0.0},
{2.0, 3.0},
{4.0, 3.0},
{6.0, 0.0}
};
for (AMCAX::GCS::Point2d& point_update : controlPoints_update) {
AMCAX::GCS::GCSWVarGeomHandle handlePoint_update;
gcsSystem.Create2dPoint(handlePoint_update, point_update);
handleControlPoints_update.push_back(handlePoint_update);
}
int degree_update = 2;
std::vector<double> weights_update = { 1.0, 1.5, 0.8, 1.0 };
std::vector<double> flatKnots_update = { 0.0, 1.0, 2.0 };
std::vector<int> multiplicities_update = { 3, 1, 3 };
AMCAX::GCS::Status status = gcsSystem.UpdateBSpline2d(handleBspline, handleControlPoints_update, weights_update, flatKnots_update, multiplicities_update, degree_update);
// Get the update b-spline curve
AMCAX::GCS::BSplineCurve2d bspline2d_update = gcsSystem.GetBSplineCurve2d(handleBspline);

Conic Sections

A conic section is defined as the intersection curve of a cone and a plane, which can be represented by a NURBS curve. Its core defining parameters include three control points and one shape factor, and the specific functions of each parameter are as follows:

1. Control Points
The three control points of a conic section are P1, P2, and P3 respectively, and their respective functions and geometric roles are as follows:

  • P1: Starting point of the curve
  • P2: Middle control point of the curve (usually not on the curve), used to control the direction and shape of the curve
  • P3: End point of the curve

Geometric Roles of Control Points:

  • P1 and P3 together define the two endpoints of the conic section, limiting the start and end range of the curve;
  • P2 is the shoulder point. The line segments P1P2 and P2P3 are the tangents of the curve at endpoints P1 and P3 respectively, which directly affect the direction and smoothness of the curve at the endpoints;
  • The three control points P1, P2, and P3 can form a control triangle (△P1P2P3).

2. Shape Factor of Conic Section
The shape factor (commonly denoted by ρ) is a key parameter determining the type of conic section, which directly decides whether the curve is ultimately an ellipse, a parabola, or a hyperbola. Its core geometric role is closely related to the weight of the middle control point P2.

Correlation between Shape Factor and Weight of P2:
In the rational Bézier formula, the weight of the middle control point P2 is usually denoted as ω₁. The correlation between the shape factor ρ and ω₁ is generally expressed as ω₁ = ρ / (1 - ρ) (the specific expression can be adjusted according to the actual implementation scenario). The two are mutually mapped and jointly affect the curve shape.

Correspondence between ρ Value and Conic Section Type:

  • When 0 < ρ < 0.5: The curve is an elliptic arc; in particular, when P1, P2, and P3 form an isosceles triangle, a circular arc can be accurately represented;​
  • When ρ = 0.5: The curve is a parabolic arc, and the corresponding rational Bézier curve degenerates into an ordinary (non-rational) quadratic Bézier curve at this time;​
  • When 0.5 < ρ < 1.0: The curve is a hyperbolic arc.

Boundary Cases: When ρ = 0 or ρ = 1, the conic section degenerates into a line segment (the connecting line between P1 and P3).

The following takes the construction of an elliptic arc as an example:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handleConicCurve;
// Array of handles to control points
std::vector< AMCAX::GCS::GCSWVarGeomHandle > handleControlPoints;
// Create three control points
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
AMCAX::GCS::Point2d p3{ 3., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
handleControlPoints = { handlePoint1, handlePoint2, handlePoint3 };
double rho = 0.3;// Shape parameter
// Create a conic curve in 2D
AMCAX::GCS::Status status = gcsSystem.Create2dConicCurve(handleConicCurve, handleControlPoints, rho);
// Solve the constraint system
gcsSystem.Solve();
// Get conic curve
AMCAX::GCS::ConicCurve2d conic = gcsSystem.GetConicCurve2d(handleConicCurve);
ConicCurve2d GetConicCurve2d(const GCSWVarGeomHandle &h) const
Get conic curve.
Status Create2dConicCurve(GCSWVarGeomHandle &h, const std::vector< GCSWVarGeomHandle > &controlPoints, double rho)
Create a conic curve in 2D.
Status Solve()
General solve. Solve the constraint system.
Conic curve in 2d.
Definition AMCAXGCS.h:229

Constraint Types

The types of constraints include horizontal, vertical, orthogonal, parallel, perpendicular, angular, distance, symmetry, equality, attachment, tangency, midpoint, and curve length constraints.

Horizontal Constraint

Create horizontal constraint between two points

After applying a horizontal constraint between two points, their y-coordinates will be the same.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleHorizontal;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a 2D horizontal constraint between point/point
gcsSystem.Create2dHorizontal(handleHorizontal, handlePoint1, handlePoint2);
// Solve the constraint system
gcsSystem.Solve();
The wrapper for GCSConHandle.
Definition AMCAXGCS.h:328
Status Create2dHorizontal(GCSWConHandle &h, GCSWVarGeomHandle &ln)
Create a 2D horizontal constraint on the line.

Create horizontal distance constraint between two points

After applying a horizontal distance constraint between two points, the difference in their x-coordinates will equal the specified distance.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleHorizontal;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a 2D horizontal distance constraint between point/point
double dis = 2.0;
gcsSystem.Create2dHorizontalDist(handleHorizontal, handlePoint1, handlePoint2, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dHorizontalDist(GCSWConHandle &h, GCSWVarGeomHandle &ln, double d)
Create a 2D horizontal distance constraint between the ends of the line.

Create horizontal constraint between line segment endpoints

After applying a horizontal constraint to a line segment's endpoints, their y-coordinates will be the same.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleHorizontal;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D horizontal constraint on the line segment
gcsSystem.Create2dHorizontal(handleHorizontal, handleLine);
// Solve the constraint system
gcsSystem.Solve();

Create horizontal distance constraint between line segment endpoints

After applying a horizontal distance constraint to a line segment's endpoints, the difference in their x-coordinates will equal the specified distance.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleHorizontal;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D horizontal distance constraint between the ends of the line segment
double dis = 2.0;
gcsSystem.Create2dHorizontalDist(handleHorizontal, handleLine, dis);
// Solve the constraint system
gcsSystem.Solve();

Vertical Constraint

Create vertical constraint between two points

After applying a vertical constraint between two points, their x-coordinates will be the same.

// Create constraint handle
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a 2D vertical constraint between point/point
gcsSystem.Create2dVertical(handleVertical, handlePoint1, handlePoint2);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dVertical(GCSWConHandle &h, GCSWVarGeomHandle &ln)
Create a 2D vertical constraint on the line.

Create vertical distance constraint between two points

After applying a vertical distance constraint between two points, the difference in their y-coordinates will equal the specified distance.

// Create constraint handle
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a 2D vertical constraint between point/point
double dis = 2.0;
gcsSystem.Create2dVerticalDist(handleVertical, handlePoint1, handlePoint2, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dVerticalDist(GCSWConHandle &h, GCSWVarGeomHandle &ln, double d)
Create a 2D vertical distance constraint between the ends of the line.

Create vertical constraint between line segment endpoints

After applying a vertical constraint to a line segment's endpoints, their x-coordinates will be the same.

// Create constraint handle
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D vertical constraint on the line segment
gcsSystem.Create2dVertical(handleVertical, handleLine);
// Solve the constraint system
gcsSystem.Solve();

Create vertical distance constraint between line segment endpoints

After applying a vertical distance constraint to a line segment's endpoints, the difference in their y-coordinates will equal the specified distance.

// Create constraint handle
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D vertical constraint on the line segment
double dis = 2.0;
gcsSystem.Create2dVerticalDist(handleVertical, handleLine, dis);
// Solve the constraint system
gcsSystem.Solve();

Orthogonal Constraint

Orthogonal constraints can be created between a line segment and a circle (arc)/ellipse (arc)/parabolic arc. After applying the orthogonal constraint, the line segment will remain perpendicular to the tangent of the curve at their intersection point. Taking a line segment and a circle as an example:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine, handleCircle, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 0. };
AMCAX::GCS::Point2d p2{ 2., 1. };
AMCAX::GCS::Point2d center{ 3., 3. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleCenter, center);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a circle in 2D
double radius = 1.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter, radius);
// Create a 2D normal constraint between line and circle
AMCAX::GCS::Status status = gcsSystem.Create2dNormal(handle2dNormal, handleLine, handleCircle);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dNormal(GCSWConHandle &h, GCSWVarGeomHandle &ln, GCSWVarGeomHandle &cur)
Create a 2D normal constraint between line and circle/ellipse/parabola.

The result is shown in the following figure:

Parallel Constraint

Parallel axial constraints can be created between line segments/ellipses (arcs)/parabolic arcs/hyperbolic arcs. The axial direction of a line segment is the direction of the line segment itself; the axial direction of an ellipse (arc) is the direction of its major axis; the axial direction of a parabola (arc) is the direction of its transverse axis; and the axial direction of a hyperbola (arc) is the direction of its transverse axis.

The following is an example of creating a parallel constraint between a line segment and an ellipse:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine1, handleCenter, handleEllipse;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 5., 3. };
AMCAX::GCS::Point2d p2{ 2., 1. };
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleCenter, center);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine1, handlePoint1, handlePoint2);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius);
// Create a 2D parallel constraint between line/ellipse
gcsSystem.Create2dParallel(handleParallel, handleLine1, handleEllipse);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dParallel(GCSWConHandle &h, GCSWVarGeomHandle &geo1, GCSWVarGeomHandle &geo2)
Create a 2D parallel constraint between two geometries with direction.

After applying the constraint, the line segment will remain parallel to the major axis of the ellipse.The result is shown in the following figure:

Perpendicular Constraint

Axial perpendicular constraints can be created between line segments and line segments/circles (arcs)/ellipses (elliptical arcs)/parabolic arcs. The axial direction of a line segment is the direction of the line segment itself; the axial direction of an ellipse (arc) is the direction of its major axis; the axial direction of a parabola (arc) is the direction of its transverse axis; and the axial direction of a hyperbola (arc) is the direction of its transverse axis.

The following is an example of creating a perpendicular constraint between a line segment and an ellipse:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine1, handleCenter, handleEllipse;
AMCAX::GCS::GCSWConHandle handlePerpendicular;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 5., 3. };
AMCAX::GCS::Point2d p2{ 2., 1. };
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleCenter, center);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine1, handlePoint1, handlePoint2);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius);
// Create a 2D perpendicular constraint between line/ellipse
AMCAX::GCS::Status status = gcsSystem.Create2dPerpendicular(handlePerpendicular, handleLine1, handleEllipse);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dPerpendicular(GCSWConHandle &h, GCSWVarGeomHandle &geo1, GCSWVarGeomHandle &geo2)
Create a 2D perpendicular constraint between two geometries with direction.

Angle Constraint

Axial Angle Constraint Between Line Segments and Ellipses (Arcs)/Parabolic Arcs/Hyperbolic Arcs

The following is an example of creating an angle constraint between a line segment and an ellipse:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine1, handleCenter, handleEllipse;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 5., 3. };
AMCAX::GCS::Point2d p2{ 2., 1. };
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleCenter, center);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine1, handlePoint1, handlePoint2);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius);
// Create a 2D angle constraint between line/ellipse
AMCAX::GCS::Status status = gcsSystem.Create2dAngVecVec(handleAng, handleLine1, handleEllipse, angle);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dAngVecVec(GCSWConHandle &h, GCSWVarGeomHandle &geo1, GCSWVarGeomHandle &geo2, double a)
Create a 2D angle constraint between two geometries with direction.
constexpr double quarter_pi
pi/4
Definition Constants.hpp:58

After applying the constraint, the included angle between the line segment and the major axis of the ellipse will be the specified angle.The result is shown in the following figure:

Angular constraint on 2D arc

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArc, handleArcstart, handleArcend, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d start{ 2., 0. };
AMCAX::GCS::Point2d end{ -2., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcstart, start);
gcsSystem.Create2dPoint(handleArcend, end);
// Create an arc in 2D
gcsSystem.Create2dArc(handleArc, handleCenter, handleArcstart, handleArcend, range);
// Crate an angle constraint on a 2D arc
gcsSystem.Create2dAngArc(handleAng, handleArc, angle);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dAngArc(GCSWConHandle &h, GCSWVarGeomHandle &arc, double a)
Crate an angle constraint on a 2D arc.

Distance Constraint

Distance constraint between two points

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a 2D distance point/point constraint
double dis = 2.0;
gcsSystem.Create2dDistPtPt(handleDisPtPt, handlePoint1, handlePoint2, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dDistPtPt(GCSWConHandle &h, GCSWVarGeomHandle &pt1, GCSWVarGeomHandle &pt2, double d)
Create a 2D distance point/point constraint.

If dis is set to 0.0, this implements a concentric constraint.

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle, handleEllipse, handleCenter_c, handleCenter_e;
// Create a point in 2D
AMCAX::GCS::Point2d center_c{ 3., 5. }, center_e{ 0., 0. };
gcsSystem.Create2dPoint(handleCenter_c, center_c);
gcsSystem.Create2dPoint(handleCenter_e, center_e);
// Create a circle in 2D
double radius = 2.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter_c, radius);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter_e, majorAxis, majorRadius, minorAxis, minorRadius);
// Create a 2D distance point/point constraint
double dis = 0.0;
gcsSystem.Create2dDistPtPt(HandleDistPtPt, handleCenter_c, handleCenter_e, dis);
// Solve the constraint system
gcsSystem.Solve();

Distance constraint between point and line segment

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 2. };
AMCAX::GCS::Point2d p2{ 3., 4. };
AMCAX::GCS::Point2d p3{ 1., 3. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D distance point / line constraint
double dis = 2.0;
gcsSystem.Create2dDistPtLn(handleDistPtLn, handlePoint3, handleLine, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dDistPtLn(GCSWConHandle &h, GCSWVarGeomHandle &pt, GCSWVarGeomHandle &ln, double d)
Create a 2D distance point/line constraint.

Distance constraint between two line segments

After applying a distance constraint between two line segments, they will remain parallel and the distance between them will be fixed to the specified value.

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handlePoint4, handleLine1, handleLine2;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 0. };
AMCAX::GCS::Point2d p3{ 1., 2. };
AMCAX::GCS::Point2d p4{ 3., 4. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
gcsSystem.Create2dPoint(handlePoint4, p4);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine1, handlePoint1, handlePoint2);
gcsSystem.Create2dLine(handleLine2, handlePoint3, handlePoint4);
// Create a 2D distance line/line constraint
double dis = 3.0;
gcsSystem.Create2dDistLnLn(handleDistLnLn, handleLine1, handleLine2, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dDistLnLn(GCSWConHandle &h, GCSWVarGeomHandle &ln1, GCSWVarGeomHandle &ln2, double d)
Create a 2D distance line/line constraint.

Symmetric Constraint

Symmetric constraint between two points about a line segment

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handlePoint4, handleLine;
AMCAX::GCS::GCSWConHandle handleSymmPtPtLn;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 0., 1. };
AMCAX::GCS::Point2d p3{ 1., 2. };
AMCAX::GCS::Point2d p4{ 3., 4. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
gcsSystem.Create2dPoint(handlePoint4, p4);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D point-point symmetric constraint with line
gcsSystem.Create2dSymmPtPtLn(handleSymmPtPtLn, handlePoint3, handlePoint4, handleLine);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dSymmPtPtLn(GCSWConHandle &h, GCSWVarGeomHandle &pt1, GCSWVarGeomHandle &pt2, GCSWVarGeomHandle &axis)
Create a 2D point-point symmetric constraint with line.

Symmetric constraint between two line segments about a line segment

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handlePoint4, handlePoint5,handlePoint6, handleLine1, handleLine2, handleLine3;
AMCAX::GCS::GCSWConHandle handleSymmLnLnLn;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ -1., 0. };
AMCAX::GCS::Point2d p2{ -2., 1. };
AMCAX::GCS::Point2d p3{ 1., 0. };
AMCAX::GCS::Point2d p4{ 2., 1. };
AMCAX::GCS::Point2d p5{ 0., 0. };
AMCAX::GCS::Point2d p6{ 0., 1. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
gcsSystem.Create2dPoint(handlePoint4, p4);
gcsSystem.Create2dPoint(handlePoint5, p5);
gcsSystem.Create2dPoint(handlePoint6, p6);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine1, handlePoint1, handlePoint2);
gcsSystem.Create2dLine(handleLine2, handlePoint3, handlePoint4);
gcsSystem.Create2dLine(handleLine3, handlePoint5, handlePoint6);
// Create a 2D line-line symmetric constraint with line
gcsSystem.Create2dSymmLnLnLn(handleSymmLnLnLn, handleLine1, handleLine2, handleLine3);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dSymmLnLnLn(GCSWConHandle &h, GCSWVarGeomHandle &ln1, GCSWVarGeomHandle &ln2, GCSWVarGeomHandle &axis)
Create a 2D line-line symmetric constraint with line.

Symmetric constraint between two circles (arcs) about a line segment

After applying a symmetric constraint between two circles (arcs) about a line segment, their centers will be symmetric about the line.

Example with circles:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle1, handleCenter1, handleCircle2, handleCenter2, handlePoint1, handlePoint2, handleLine;
AMCAX::GCS::GCSWConHandle handleSymmCirCirLn;
// Create a point in 2D
AMCAX::GCS::Point2d center1{ 0., 0. };
AMCAX::GCS::Point2d center2{ 3., 3. };
AMCAX::GCS::Point2d point1{ 2., 0. };
AMCAX::GCS::Point2d point2{ 2., 2. };
gcsSystem.Create2dPoint(handleCenter1, center1);
gcsSystem.Create2dPoint(handleCenter2, center2);
gcsSystem.Create2dPoint(handlePoint1, point1);
gcsSystem.Create2dPoint(handlePoint2, point2);
// Create a circle in 2D
double radius = 1.0;
gcsSystem.Create2dCircle(handleCircle1, handleCenter1, radius);
gcsSystem.Create2dCircle(handleCircle2, handleCenter2, radius);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a 2D circle-circle symmetric constraint with line
AMCAX::GCS::Status status = gcsSystem.Create2dSymmCirCirLn(handleSymmCirCirLn, handleCircle1, handleCircle2, handleLine);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dSymmCirCirLn(GCSWConHandle &h, GCSWVarGeomHandle &cir1, GCSWVarGeomHandle &cir2, GCSWVarGeomHandle &axis)
Create a 2D circle-circle symmetric constraint with line.

Equal Constraint

Supports equal constraints between line segments/line segments, circles(arcs)/circles(arcs), and ellipses(elliptical arcs)/ellipses(elliptical arcs). After applying an equal constraint between line segments, their lengths will be equal; between circles(arcs), their radii will be equal; between ellipses(elliptical arcs), their major and minor radii will be equal.
Example with circles:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle1, handleCenter1, handleCircle2, handleCenter2;
// Create a point in 2D
AMCAX::GCS::Point2d center1{ 0., 0. };
AMCAX::GCS::Point2d center2{ 4., 4. };
gcsSystem.Create2dPoint(handleCenter1, center1);
gcsSystem.Create2dPoint(handleCenter2, center2);
// Create a circle in 2D
double radius1 = 1.0;
double radius2 = 2.0;
gcsSystem.Create2dCircle(handleCircle1, handleCenter1, radius1);
gcsSystem.Create2dCircle(handleCircle2, handleCenter2, radius2);
// Create a 2D equal constraint between circle/circle
gcsSystem.Create2dEqual(handleEqual, handleCircle1, handleCircle2);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dEqual(GCSWConHandle &h, GCSWVarGeomHandle &g1, GCSWVarGeomHandle &g2)
Create a 2D equal constraint between line/line, circle/circle or ellipse/ellipse.

Attachment Constraint

Supports attaching points to line segments, circles (arcs), ellipses (arcs), hyperbolic arcs, parabolic arcs, B-splines, and conic curves.
Example of attaching a point to a circle:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle, handleCenter, handlePoint;
AMCAX::GCS::GCSWConHandle handlePtOnObject;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d point{ 2., 3. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handlePoint, point);
// Create a circle in 2D
double radius = 1.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter, radius);
// Create a constraint to attach the point to the circle
gcsSystem.Create2dPtOnObject(handlePtOnObject, handlePoint, handleCircle);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dPtOnObject(GCSWConHandle &h, GCSWVarGeomHandle &pt, GCSWVarGeomHandle &geom)
Create a constraint to attach the point to the object.

Tangent Constraint

Tangent constraint between line segment and circle (arc)

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine, handleCircle, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 2. };
AMCAX::GCS::Point2d p2{ 3., 4. };
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleCenter, center);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a circle in 2D
double radius = 2.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter, radius);
// Create a 2D tangent line/circle constraint
double dis = 0.0;
gcsSystem.Create2dTanLnCir(handleTanLnCir, handleLine, handleCircle, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanLnCir(GCSWConHandle &h, GCSWVarGeomHandle &ln, GCSWVarGeomHandle &cir, double d)
Create a 2D tangent line/circle constraint.

Tangent constraint between line segment and ellipse (elliptical arc)

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine, handleEllipse, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 2. };
AMCAX::GCS::Point2d p2{ 3., 4. };
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleCenter, center);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius);
// Create a 2D tangent line/ellipse constraint
gcsSystem.Create2dTanLnEll(handleTanLnEll, handleLine, handleEllipse);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanLnEll(GCSWConHandle &h, GCSWVarGeomHandle &ln, GCSWVarGeomHandle &ellipse)
Create a 2D tangent line/ellipse constraint.

Tangent constraint between line segment and parabolic arc

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine, handleArcOfParabola, handleArcOfParabolafocus, handleArcOfParabolavertex, handleArcOfParabolastart, handleArcOfParabolaend;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 2. };
AMCAX::GCS::Point2d p2{ -3., 4. };
AMCAX::GCS::Point2d focus{ 1., 0. };
AMCAX::GCS::Point2d vertex{ 0., 0. };
AMCAX::GCS::Point2d start{ 1., 2. };
AMCAX::GCS::Point2d end{ 1., -2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handleArcOfParabolafocus, focus);
gcsSystem.Create2dPoint(handleArcOfParabolavertex, vertex);
gcsSystem.Create2dPoint(handleArcOfParabolastart, start);
gcsSystem.Create2dPoint(handleArcOfParabolaend, end);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create an arc of parabola in 2D
gcsSystem.Create2dArcOfParabola(handleArcOfParabola, handleArcOfParabolafocus, vertex, handleArcOfParabolastart, handleArcOfParabolaend);
// Create a 2D tangent line / parabola constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanLnPar(handleTanLnPar, handleLine, handleArcOfParabola);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanLnPar(GCSWConHandle &h, GCSWVarGeomHandle &line, GCSWVarGeomHandle &parabola)
Create a 2D tangent line/parabola constraint.

Tangent constraint between line segment and B-spline curve

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handleLine, handleBspline;
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints;
std::vector<AMCAX::GCS::Point2d> controlPoints{
{0.,0.},
{1.,1.},
{2.,2.},
{3.,-5.},
{0.,0.} };
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
AMCAX::GCS::GCSWConHandle handleTanLnBSpline;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 1., 2. };
AMCAX::GCS::Point2d p2{ 3., 4. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine, handlePoint1, handlePoint2);
// Create a non-rational cubic B-spline curve in 2D
std::vector<double> knotSequence{ 0.,0., 0.25, 0.5,0.75,1.,1.,1.,1. };
gcsSystem.Create2dCubicBSplineCurve(handleBspline, handleControlPoints, knotSequence);
// Create a 2D tangent line/b-spline constraint
gcsSystem.Create2dTanLnBSpline(handleTanLnBSpline, handleLine, handleBspline);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanLnBSpline(GCSWConHandle &h, GCSWVarGeomHandle &line, GCSWVarGeomHandle &spline)
Create a 2D tangent line/b-spline constraint.

Tangent constraint between line segment and Conic Curve

// Create handles for geometric entities and constraints
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handleConicCurve, handlePoint4, handlePoint5, handleLine;
AMCAX::GCS::GCSWConHandle handleConicCircular, handleTanLnConic;
// Array of handles to control points of the conic curve
std::vector< AMCAX::GCS::GCSWVarGeomHandle > handleControlPoints;
// Create 2D points (control points for conic curve and endpoints for line segment)
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 1. };
AMCAX::GCS::Point2d p3{ 2., 0. };
AMCAX::GCS::Point2d p4{ 1., 2. };
AMCAX::GCS::Point2d p5{ 3., 4. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
gcsSystem.Create2dPoint(handlePoint4, p4);
gcsSystem.Create2dPoint(handlePoint5, p5);
handleControlPoints = { handlePoint1, handlePoint2, handlePoint3 };
// Create a 2D line segment (defined by two endpoints p4 and p5)
gcsSystem.Create2dLine(handleLine, handlePoint4, handlePoint5);
// Create a 2D conic curve with specified shape parameter ρ
double rho = 0.5;// Shape parameter (0.5 for parabolic arc)
gcsSystem.Create2dConicCurve(handleConicCurve, handleControlPoints, rho);
// Create a constraint to make the line segment tangent to the conic curve in 2D
AMCAX::GCS::Status status = gcsSystem.Create2dTanLnConic(handleTanLnConic, handleLine, handleConicCurve);
// Solve the constraint system to apply the tangency constraint
gcsSystem.Solve();
Status Create2dTanLnConic(GCSWConHandle &h, GCSWVarGeomHandle &line, GCSWVarGeomHandle &conic)
Create a 2D tangent line/conic constraint.

Tangent constraint between circle (arc) and circle (arc)

When creating a tangent constraint between circles (arcs), the VecSense parameter specifies whether the tangency is internal or external. kCodirectional indicates external tangency, kOpposed indicates internal tangency.

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle1, handleCenter1, handleCircle2, handleCenter2;
AMCAX::GCS::GCSWConHandle handleTanCirCir;
// Create a point in 2D
AMCAX::GCS::Point2d center1{ 0., 0. };
AMCAX::GCS::Point2d center2{ 1., 1. };
gcsSystem.Create2dPoint(handleCenter1, center1);
gcsSystem.Create2dPoint(handleCenter2, center2);
// Create a circle in 2D
double radius1 = 2.0;
double radius2 = 1.0;
gcsSystem.Create2dCircle(handleCircle1, handleCenter1, radius1);
gcsSystem.Create2dCircle(handleCircle2, handleCenter2, radius2);
// Create a 2D tangent circle/circle constraint
double dis = 0.0;
AMCAX::GCS::Status status = gcsSystem.Create2dTanCirCir(handleTanCirCir, handleCircle1, handleCircle2, AMCAX::GCS::VecSense::kCodirectional, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanCirCir(GCSWConHandle &h, GCSWVarGeomHandle &circle1, GCSWVarGeomHandle &circle2, VecSense vecSense, double d)
Create a 2D tangent circle/circle constraint.
@ kCodirectional
Same direction.
Definition AMCAXGCS.h:250

Tangent constraint between circle (arc) and ellipse (elliptical arc)

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle, handleEllipse, handleCenter_c, handleCenter_e;
AMCAX::GCS::GCSWConHandle handleTanCirEll;
// Create a point in 2D
AMCAX::GCS::Point2d center_c{ 0., 0. };
AMCAX::GCS::Point2d center_e{ 2., 1. };
gcsSystem.Create2dPoint(handleCenter_c, center_c);
gcsSystem.Create2dPoint(handleCenter_e, center_e);
// Create a circle in 2D
double radius = 2.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter_c, radius);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter_e, majorAxis, majorRadius, minorAxis, minorRadius);
// Create a 2D tangent circle/ellipse constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanCirEll(handleTanCirEll, handleCircle, handleEllipse);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanCirEll(GCSWConHandle &h, GCSWVarGeomHandle &circle, GCSWVarGeomHandle &ellipse)
Create a 2D tangent circle/ellipse constraint.

Tangent constraint between circle (arc) and parabolic arc

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle, handleCenter, handleArcOfParabola, handleArcOfParabolafocus, handleArcOfParabolavertex, handleArcOfParabolastart, handleArcOfParabolaend;
AMCAX::GCS::GCSWConHandle handleTanCirPar;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d focus{ 1., 0. };
AMCAX::GCS::Point2d vertex{ 0., 0. };
AMCAX::GCS::Point2d start{ 1., 2. };
AMCAX::GCS::Point2d end{ 1., -2. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcOfParabolafocus, focus);
gcsSystem.Create2dPoint(handleArcOfParabolavertex, vertex);
gcsSystem.Create2dPoint(handleArcOfParabolastart, start);
gcsSystem.Create2dPoint(handleArcOfParabolaend, end);
// Create a circle in 2D
double radius = 2.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter, radius);
// Create an arc of parabola in 2D
gcsSystem.Create2dArcOfParabola(handleArcOfParabola, handleArcOfParabolafocus, vertex, handleArcOfParabolastart, handleArcOfParabolaend);
// Create a 2D tangent circle/parabola constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanCirPar(handleTanCirPar, handleCircle, handleArcOfParabola);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanCirPar(GCSWConHandle &h, GCSWVarGeomHandle &circle, GCSWVarGeomHandle &parabola)
Create a 2D tangent circle/parabola constraint.

angent constraint between circle (arc) and B-spline curve

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleCircle, handleCenter, handleBspline;
std::vector<AMCAX::GCS::GCSWVarGeomHandle> handleControlPoints;
std::vector<AMCAX::GCS::Point2d> controlPoints{
{0.,0.},
{1.,1.},
{2.,2.},
{3.,-5.},
{0.,0.} };
for (AMCAX::GCS::Point2d& point : controlPoints) {
gcsSystem.Create2dPoint(handlePoint, point);
handleControlPoints.push_back(handlePoint);
}
AMCAX::GCS::GCSWConHandle handleTanCirBSpline;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
// Create a circle in 2D
double radius = 1.0;
gcsSystem.Create2dCircle(handleCircle, handleCenter, radius);
// Create a non-rational cubic B-spline curve in 2D
std::vector<double> knotSequence{ 0.,0., 0.25, 0.5,0.75,1.,1.,1.,1. };
gcsSystem.Create2dCubicBSplineCurve(handleBspline, handleControlPoints, knotSequence);
// Create a 2D tangent circle/b-spline constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanCirBSpline(handleTanCirBSpline, handleCircle, handleBspline);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanCirBSpline(GCSWConHandle &h, GCSWVarGeomHandle &circle, GCSWVarGeomHandle &spline)
Create a 2D tangent circle/b-spline constraint.

Tangent constraint between ellipse (elliptical arc) and ellipse (elliptical arc)

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleEllipse1, handleEllipse2, handleCenter1, handleCenter2;
AMCAX::GCS::GCSWConHandle handleTanEllEll;
// Create a point in 2D
AMCAX::GCS::Point2d center1{ 0., 0. };
AMCAX::GCS::Point2d center2{ 1., 1. };
gcsSystem.Create2dPoint(handleCenter1, center1);
gcsSystem.Create2dPoint(handleCenter2, center2);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis1{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis1{ 0.,1. };
AMCAX::GCS::Vector2d majorAxis2{ 1.,1. };
AMCAX::GCS::Vector2d minorAxis2{ -1.,1. };
double majorRadius1 = 2.0;
double minorRadius1 = 1.0;
double majorRadius2 = 3.0;
double minorRadius2 = 1.5;
gcsSystem.Create2dEllipse(handleEllipse1, handleCenter1, majorAxis1, majorRadius1, minorAxis1, minorRadius1);
gcsSystem.Create2dEllipse(handleEllipse2, handleCenter2, majorAxis2, majorRadius2, minorAxis2, minorRadius2);
// Create a 2D tangent ellipse/ellipse constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanEllEll(handleTanEllEll, handleEllipse1, handleEllipse2);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanEllEll(GCSWConHandle &h, GCSWVarGeomHandle &ellipse1, GCSWVarGeomHandle &ellipse2)
Create a 2D tangent ellipse/ellipse constraint.

Tangent constraint between ellipse (elliptical arc) and parabolic arc

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleEllipse, handleCenter, handleArcOfParabola, handleArcOfParabolafocus, handleArcOfParabolavertex, handleArcOfParabolastart, handleArcOfParabolaend;
AMCAX::GCS::GCSWConHandle handleTanEllPar;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 1., 1. };
AMCAX::GCS::Point2d focus{ 1., 0. };
AMCAX::GCS::Point2d vertex{ 0., 0. };
AMCAX::GCS::Point2d start{ 1., 2. };
AMCAX::GCS::Point2d end{ 1., -2. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcOfParabolafocus, focus);
gcsSystem.Create2dPoint(handleArcOfParabolavertex, vertex);
gcsSystem.Create2dPoint(handleArcOfParabolastart, start);
gcsSystem.Create2dPoint(handleArcOfParabolaend, end);
// Create an ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,1. };
AMCAX::GCS::Vector2d minorAxis{ -1.,1. };
double majorRadius = 3.0;
double minorRadius = 1.5;
gcsSystem.Create2dEllipse(handleEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius);
// Create an arc of parabola in 2D
gcsSystem.Create2dArcOfParabola(handleArcOfParabola, handleArcOfParabolafocus, vertex, handleArcOfParabolastart, handleArcOfParabolaend);
// Create a 2D tangent ellipse/parabola arc constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanEllPar(handleTanEllPar, handleEllipse, handleArcOfParabola);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanEllPar(GCSWConHandle &h, GCSWVarGeomHandle &ellipse, GCSWVarGeomHandle &parabola)
Create a 2D tangent ellipse/parabola constraint.

Tangent constraint between parabolic arc and parabolic arc

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArcOfParabola1, handleArcOfParabolafocus1, handleArcOfParabolavertex1, handleArcOfParabolastart1, handleArcOfParabolaend1, handleArcOfParabola2, handleArcOfParabolafocus2, handleArcOfParabolavertex2, handleArcOfParabolastart2, handleArcOfParabolaend2;
AMCAX::GCS::GCSWConHandle handleTanParPar;
// Create a point in 2D
AMCAX::GCS::Point2d focus1{ 1., 0. };
AMCAX::GCS::Point2d vertex1{ 0., 0. };
AMCAX::GCS::Point2d start1{ 1., 2. };
AMCAX::GCS::Point2d end1{ 1., -2. };
AMCAX::GCS::Point2d focus2{ 0., 2. };
AMCAX::GCS::Point2d vertex2{ 0., 1. };
AMCAX::GCS::Point2d start2{ -2., 2. };
AMCAX::GCS::Point2d end2{ 2., 2. };
gcsSystem.Create2dPoint(handleArcOfParabolafocus1, focus1);
gcsSystem.Create2dPoint(handleArcOfParabolavertex1, vertex1);
gcsSystem.Create2dPoint(handleArcOfParabolastart1, start1);
gcsSystem.Create2dPoint(handleArcOfParabolaend1, end1);
gcsSystem.Create2dPoint(handleArcOfParabolafocus2, focus2);
gcsSystem.Create2dPoint(handleArcOfParabolavertex2, vertex2);
gcsSystem.Create2dPoint(handleArcOfParabolastart2, start2);
gcsSystem.Create2dPoint(handleArcOfParabolaend2, end2);
// Create an arc of parabola
gcsSystem.Create2dArcOfParabola(handleArcOfParabola1, handleArcOfParabolafocus1, vertex1, handleArcOfParabolastart1, handleArcOfParabolaend1);
gcsSystem.Create2dArcOfParabola(handleArcOfParabola2, handleArcOfParabolafocus2, vertex2, handleArcOfParabolastart2, handleArcOfParabolaend2);
// Create a 2D tangent parabola/parabola constraint
AMCAX::GCS::Status status = gcsSystem.Create2dTanParPar(handleTanParPar, handleArcOfParabola1, handleArcOfParabola2);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dTanParPar(GCSWConHandle &h, GCSWVarGeomHandle &parabola1, GCSWVarGeomHandle &parabola2)
Create a 2D tangent parabola/parabola constraint.

Midpoint Constraint

Supports midpoint constraints on line segments and arcs. Example with an arc:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArcOfEllipse, handleArcOfEllipsestart, handleArcOfEllipseend, handleCenter, handlePoint;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d start{ 2., 0. };
AMCAX::GCS::Point2d end{ -2., 0. };
AMCAX::GCS::Point2d point{ 3., 5. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcOfEllipsestart, start);
gcsSystem.Create2dPoint(handleArcOfEllipseend, end);
gcsSystem.Create2dPoint(handlePoint, point);
// Create an arc of ellipse in 2D
AMCAX::GCS::Vector2d majorAxis{ 1.,0. };
AMCAX::GCS::Vector2d minorAxis{ 0.,1. };
double majorRadius = 2.0;
double minorRadius = 1.0;
gcsSystem.Create2dArcOfEllipse(handleArcOfEllipse, handleCenter, majorAxis, majorRadius, minorAxis, minorRadius, handleArcOfEllipsestart, handleArcOfEllipseend, range);
// Create a midpoint on the ellipse arc
AMCAX::GCS::Status status = gcsSystem.Create2dMidPoint(handleMidPoint, handlePoint, handleArcOfEllipse);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dMidPoint(GCSWConHandle &h, GCSWVarGeomHandle &p, GCSWVarGeomHandle &cur)
Create a midpoint on the line segment/arc.

Curve Length Constraint

Supported curve types include arcs, ellipses, conic arcs (elliptical arcs, parabolic arcs, hyperbolic arcs), and B-spline curves. Take an arc as an example:

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handleArc, handleArcstart, handleArcend, handleCenter;
// Create a point in 2D
AMCAX::GCS::Point2d center{ 0., 0. };
AMCAX::GCS::Point2d start{ 2., 0. };
AMCAX::GCS::Point2d end{ -2., 0. };
gcsSystem.Create2dPoint(handleCenter, center);
gcsSystem.Create2dPoint(handleArcstart, start);
gcsSystem.Create2dPoint(handleArcend, end);
// Create an arc in 2D
gcsSystem.Create2dArc(handleArc, handleCenter, handleArcstart, handleArcend, range);
// Create a 2D curve length constraint
double len = 0.2;
AMCAX::GCS::Status status = gcsSystem.Create2dCurLen(handleCurLen, handleArc, len);
// Solve the constraint system
gcsSystem.Solve();
Status Create2dCurLen(GCSWConHandle &h, GCSWVarGeomHandle &cur, double len)
Create a 2D curve length constraint.

Shape Parameter ρ Constraint

Add a shape parameter constraint to the target conic curve to forcibly fix its shape factor ρ to a specified numerical value.

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handleConicCurve;
// Array of handles to control points
std::vector< AMCAX::GCS::GCSWVarGeomHandle > handleControlPoints;
// Create three control points
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
AMCAX::GCS::Point2d p3{ 3., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
handleControlPoints = { handlePoint1, handlePoint2, handlePoint3 };
double rho = 0.3;// Shape parameter
// Create a conic curve in 2D
gcsSystem.Create2dConicCurve(handleConicCurve, handleControlPoints, rho);
// Create a constraint to the rho parameter of conic curve
double rho_new = 0.5;
AMCAX::GCS::Status status = gcsSystem.Create2dConicRho(handleRho, handleConicCurve, rho_new);
// Solve the constraint system
gcsSystem.Solve();
// Get conic curve
AMCAX::GCS::ConicCurve2d conic = gcsSystem.GetConicCurve2d(handleConicCurve);
Status Create2dConicRho(GCSWConHandle &h, GCSWVarGeomHandle &conic, double rho)
Create a constraint to the rho parameter of conic curve.

Circular Arc Constraint

Constrain the target conic curve to a standard circular arc. After applying this constraint, the three control points P1, P2, and P3 will form an isosceles triangle.

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handleConicCurve;
// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handleConicCurve;
AMCAX::GCS::GCSWConHandle handleConicCircular;
// Array of handles to control points
std::vector< AMCAX::GCS::GCSWVarGeomHandle > handleControlPoints;
// Create three control points
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 1. };
AMCAX::GCS::Point2d p3{ 2., 0. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
handleControlPoints = { handlePoint1, handlePoint2, handlePoint3 };
double rho = 0.5;// Shape parameter
// Create a conic curve in 2D
gcsSystem.Create2dConicCurve(handleConicCurve, handleControlPoints, rho);
// Create a circular constraint to the conic curve
AMCAX::GCS::Status status = gcsSystem.Create2dConicCircular(handleConicCircular, handleConicCurve);
// Solve the constraint system
gcsSystem.Solve();
// Get conic curve
AMCAX::GCS::ConicCurve2d conic = gcsSystem.GetConicCurve2d(handleConicCurve);
Status Create2dConicCircular(GCSWConHandle &h, GCSWVarGeomHandle &conic)
Create a circular constraint to the conic curve.

Detecting Redundant Constraints

When adding constraints, redundant or conflicting constraints may occur. The following example illustrates this:

In the figure below, only two parallel constraints are needed to ensure pairwise parallelism between three line segments. Adding three parallel constraints makes one of them redundant.

When redundant or conflicting constraints exist in the GCS, the system will report the over-constrained range through GCSWConHandle::IsOverConstrained. If IsOverConstrained=true, the Handle's corresponding constraint is marked as over-constrained.

// Create constraint handle
AMCAX::GCS::GCSWVarGeomHandle handlePoint1, handlePoint2, handlePoint3, handlePoint4, handleLine1, handleLine2, handleLine3;
AMCAX::GCS::GCSWConHandle handleParallel1, handleParallel2, handleParallel3;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 0. };
AMCAX::GCS::Point2d p3{ 1., 2. };
AMCAX::GCS::Point2d p4{ 3., 4. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
gcsSystem.Create2dPoint(handlePoint3, p3);
gcsSystem.Create2dPoint(handlePoint4, p4);
// Create a line segment in 2D
gcsSystem.Create2dLine(handleLine1, handlePoint1, handlePoint2);
gcsSystem.Create2dLine(handleLine2, handlePoint1, handlePoint3);
gcsSystem.Create2dLine(handleLine3, handlePoint1, handlePoint4);
// Create a 2D parallel constraint between line/line
gcsSystem.Create2dParallel(handleParallel1, handleLine1, handleLine2);
gcsSystem.Create2dParallel(handleParallel2, handleLine1, handleLine3);
gcsSystem.Create2dParallel(handleParallel3, handleLine2, handleLine3);
// Solve the constraint system
gcsSystem.Solve();
// Is the handle related to over-constrained part
std::cout << (handleParallel1.IsOverConstrained() || handleParallel2.IsOverConstrained() || handleParallel3.IsOverConstrained()) << std::endl;// 1
bool IsOverConstrained() const
Is the handle related to over-constrained part.

3D Constraint Solving

Constraint Element Types

Constraint element types include points, lines, and planes.

Constraint Types

Constraint types include parallel, distance, angle, and symmetry.

Distance Constraints

Distance Constraint Between Two Points

After applying a distance constraint between two points, the distance between them will be fixed to the specified value.

// Create constraint handle
// Create point
p1.x = 1.;
p1.y = 2.;
p1.z = 3.;
p2.x = 4.;
p2.y = 5.;
p2.z = 6.;
// Create rigid body
// Create a 3D distance point/point constraint
double dis = 2.0;
AMCAX::GCS::Status status = gcsSystem.Create3dDistPtPt(handleDistPtPt, body1, body2, p1, p2, dis);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated point
AMCAX::GCS::Point3d p1_update = gcsSystem.UpdatePoint3dPosition(body1, p1);
AMCAX::GCS::Point3d p2_update = gcsSystem.UpdatePoint3dPosition(body2, p2);
The wrapper for GCSRigidBody.
Definition AMCAXGCS.h:302
GCSWRigidBody CreateRigidBody(unsigned int id)
Create rigid body from the id.
Point3d UpdatePoint3dPosition(const GCSWRigidBody &body, const Point3d &point)
Update the point position based on the transformation of the rigid body.
Status Create3dDistPtPt(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Point3d &pt1, const Point3d &pt2, double d)
Create a 3D distance point/point constraint.
Point.
Definition AMCAXGCS.h:36

Distance Constraint Between Point and Line

After applying a distance constraint between a point and a line, the distance from the point to the line will be fixed to the specified value.

// Create constraint handle
// Create point
p1.x = 1.;
p1.y = 2.;
p1.z = 3.;
p2.x = 4.;
p2.y = 5.;
p2.z = 6.;
p3.x = -1.;
p3.y = 1.5;
p3.z = -2.;
// Create vector
vec.x = p2.x - p1.x;
vec.y = p2.y - p1.y;
vec.z = p2.z - p1.z;
// Create line
line.origin = p1;
line.direction = vec;
// Create rigid body
// Create a 3D distance point/line constraint
double dis = 2.0;
AMCAX::GCS::Status status = gcsSystem.Create3dDistPtLn(handleDistPtLn, body1, body2, p3, line, dis);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated point and line
AMCAX::GCS::Point3d p3_update = gcsSystem.UpdatePoint3dPosition(body1, p3);
AMCAX::GCS::Line3d line_update = gcsSystem.UpdateLine3dPosition(body2, line);
Line3d UpdateLine3dPosition(const GCSWRigidBody &body, const Line3d &line)
Update the line based on the transformation of the rigid body.
Status Create3dDistPtLn(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Point3d &pt, const Line3d &ln, double d)
Create a 3D distance point/line constraint.
Line represented by a point and the normalized direction vector.
Definition AMCAXGCS.h:54
Point3d origin
A point on the line.
Definition AMCAXGCS.h:58
Vector3d direction
Normalized line direction vector.
Definition AMCAXGCS.h:62
Vector.
Definition AMCAXGCS.h:45

Distance Constraint Between Point and Plane

After applying a distance constraint between a point and a plane, the distance from the point to the plane will be fixed to the specified value.

// Create constraint handle
// Create point
p1.x = 1.;
p1.y = 2.;
p1.z = 3.;
p2.x = 0.;
p2.y = 0.;
p2.z = 1.;
origin.x = 0.;
origin.y = 0.;
origin.z = 0.;
// Create vector
normal.x = p2.x - origin.x;
normal.y = p2.y - origin.y;
normal.z = p2.z - origin.z;
// Create line
line.origin = p1;
line.direction = normal;
// Create plane
plane.origin = origin;
plane.normal = normal;
// Create rigid body
// Create a 3D distance point/plane constraint
double dis = 0.5;
gcsSystem.Create3dDistPtPl(handleDistPtPl, body1, body2, p1, plane, dis);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated point and plane
AMCAX::GCS::Point3d p1_update = gcsSystem.UpdatePoint3dPosition(body1, p1);
AMCAX::GCS::Plane plane_update = gcsSystem.UpdatePlanePosition(body2, plane);
Plane UpdatePlanePosition(const GCSWRigidBody &body, const Plane &plane)
Update the plane based on the transformation of the rigid body.
Status Create3dDistPtPl(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Point3d &pt, const Plane &pl, double d)
Create a 3D distance point/plane constraint.
Plane represented by a point and the normalized normal vector.
Definition AMCAXGCS.h:68
Vector3d normal
Normalized normal vector.
Definition AMCAXGCS.h:76
Point3d origin
A point on the plane.
Definition AMCAXGCS.h:72

Distance Constraint Between Point and Torus

After applying a distance constraint between a point and a torus, the distance from the point to the torus will be fixed at the specified value.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleDistPtTorus;
// Create point
p1.x = 0.;
p1.y = 0.;
p1.z = 0.;
p2.x = 10.;
p2.y = 10.;
p2.z = 10.;
// Create vector
normal.x = 0.;
normal.y = 0.;
normal.z = 1.;
// Create torus
torus.center = p1;
torus.normal = normal;
torus.majorRadius = 10.0;
torus.minorRadius = 5.0;
// Create rigid body
body1 = gcsSystem.CreateRigidBody(1);
body2 = gcsSystem.CreateRigidBody(2);
// Create a 3D distance point/torus constraint
double dis = 1.;// Distance between point and torus
gcsSystem.Create3dDistPtTorus(handleDistPtTorus, body1, body2, p2, torus, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create3dDistPtTorus(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Point3d &pt, const Torus &tor, double d)
Create a 3D distance point/torus constraint.
Torus represented by a circular spine and the radius of circular cross-section.
Definition AMCAXGCS.h:83
Point3d center
Center of the spine curve.
Definition AMCAXGCS.h:87
double majorRadius
Radius of the spine curve.
Definition AMCAXGCS.h:95
double minorRadius
Radius of the circular cross-section.
Definition AMCAXGCS.h:99
Vector3d normal
Normal to the plane of the spline.
Definition AMCAXGCS.h:91

Distance Constraint Between Two Lines

After applying a distance constraint between two lines, they will remain parallel and the distance between them will be fixed to the specified value.

When applying distance constraints between two line segments in 3D space, there may be infinitely many solutions. To address this, we introduced the VecSense parameter to help the system filter solutions that align with the design intent.

When VecSense is set to kCodirectional, the two line segments have the same direction;

When VecSense is set to kOpposed, the two line segments have opposite directions;

When VecSense is set to kParallel, the line segments are parallel with arbitrary direction;

When VecSense is set to kReference, the effect is the same as kParallel.

// Create constraint handle
// Create point
p1.x = 1.;
p1.y = 2.;
p1.z = 3.;
p2.x = 4.;
p2.y = 5.;
p2.z = 6.;
p3.x = -1.;
p3.y = 1.5;
p3.z = -2.;
p3.x = 0.;
p3.y = -3.;
p3.z = 2.;
// Create vector
vec1.x = p2.x - p1.x;
vec1.y = p2.y - p1.y;
vec1.z = p2.z - p1.z;
vec2.x = p4.x - p3.x;
vec2.y = p4.y - p3.y;
vec2.z = p4.z - p3.z;
// Create line
line1.origin = p1;
line1.direction = vec1;
line2.origin = p3;
line2.direction = vec2;
// Create rigid body
// Create a 3D distance line/line constraint
double dis = 2.0;
AMCAX::GCS::Status status = gcsSystem.Create3dDistLnLn(handleDistLnLn, body1, body2, line1, line2, dis, vecSense);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated line
AMCAX::GCS::Line3d line1_update = gcsSystem.UpdateLine3dPosition(body1, line1);
AMCAX::GCS::Line3d line2_update = gcsSystem.UpdateLine3dPosition(body2, line2);
Status Create3dDistLnLn(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Line3d &ln1, const Line3d &ln2, double d, VecSense vecSense)
Create a 3D distance line/line constraint. The two lines are forced to be parallel.

Distance Constraint Between Line Segment and Plane

After applying a distance constraint between a line segment and a plane, the line segment will maintain a parallel relationship with the plane, and the distance between them will be fixed at the specified value.

// Create constraint handle
// Create point
p1.x = 1.;
p1.y = 2.;
p1.z = 3.;
p2.x = 4.;
p2.y = 5.;
p2.z = 6.;
p3.x = 0.;
p3.y = 0.;
p3.z = 0.;
p4.x = 0.;
p4.y = 0.;
p4.z = 1.;
// Create vector
direction.x = p2.x - p1.x;
direction.y = p2.y - p1.y;
direction.z = p2.z - p1.z;
normal.x = p4.x - p3.x;
normal.y = p4.y - p3.y;
normal.z = p4.z - p3.z;
// Create line
line.origin = p1;
line.direction = direction;
// Create plane
plane.origin = p3;
plane.normal = normal;
// Create rigid body
// Create a 3D distance line/plane constraint
double dis = 0.5;
AMCAX::GCS::Status status = gcsSystem.Create3dDistLnPl(handleDistLnPl, body1, body2, line, plane, dis);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated line and plane
AMCAX::GCS::Line3d line_update = gcsSystem.UpdateLine3dPosition(body1, line);
AMCAX::GCS::Plane plane_update = gcsSystem.UpdatePlanePosition(body2, plane);
Status Create3dDistLnPl(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Line3d &ln, const Plane &pl, double d)
Create a 3D distance line/plane constraint.

Distance Constraint Between Two Planes

After applying a distance constraint between two planes, they will maintain a ​​parallel relationship​​, and the distance between them will be ​​fixed at the specified value​​.

// Create constraint handle
// Create point
p1.x = 1.;
p1.y = 2.;
p1.z = 3.;
p2.x = 4.;
p2.y = 5.;
p2.z = 6.;
p3.x = 0.;
p3.y = 0.;
p3.z = 0.;
p4.x = 0.;
p4.y = 0.;
p4.z = 1.;
// Create vector
normal1.x = p2.x - p1.x;
normal1.y = p2.y - p1.y;
normal1.z = p2.z - p1.z;
normal2.x = p4.x - p3.x;
normal2.y = p4.y - p3.y;
normal2.z = p4.z - p4.z;
// Create plane
plane1.origin = p1;
plane1.normal = normal1;
plane2.origin = p3;
plane2.normal = normal2;
// Create rigid body
// Create a 3D distance plane/plane constraint
double dis = 0.5;
AMCAX::GCS::Status status = gcsSystem.Create3dDistPlPl(handleDistPlPl, body1, body2, plane1, plane2, vecSence, dis);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated plane
AMCAX::GCS::Plane plane1_update = gcsSystem.UpdatePlanePosition(body1, plane1);
AMCAX::GCS::Plane plane2_update = gcsSystem.UpdatePlanePosition(body2, plane2);
Status Create3dDistPlPl(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Plane &pl1, const Plane &pl2, VecSense vecSense, double d)
Create a 3D distance plane/plane constraint.

Distance Constraint Between Plane and Torus

After applying a distance constraint between a plane and a torus, the distance between them will be fixed at the specified value.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleDistPlTorus;
// Create point
p1.x = 10.;
p1.y = 10.;
p1.z = 10.;
p2.x = 0.;
p2.y = 0.;
p2.z = 0.;
// Create vector
normal1.x = 0.;
normal1.y = 0.;
normal1.z = 1.;
normal2.x = 1.;
normal2.y = 0.;
normal2.z = 0.;
// Create plane
plane.origin = p1;
plane.normal = normal1;
// Create torus
torus.center = p2;
torus.normal = normal2;
torus.majorRadius = 10.0;
torus.minorRadius = 2.0;
// Create rigid body
// Create a 3D distance plane/torus constraint
double dis = 10.;
gcsSystem.Create3dDistPlTorus(handleDistPlTorus, body1, body2, plane, torus, dis);
// Solve the constraint system
gcsSystem.Solve();
Status Create3dDistPlTorus(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Plane &pl, const Torus &tor, double d)
Create a 3D distance plane/torus constraint.

Angle Constraint

When applying angle constraints between two vectors in 3D space, there may be infinitely many solutions. To address this, we introduced the VecSense parameter to help the system filter solutions that align with the design intent.

When VecSense is set to kCodirectional, the vectors satisfy:

When VecSense is set to kOpposed, the vectors satisfy:

When VecSense is set to kParallel, the vectors can be either codirectional or opposed;

When VecSense is set to kReference, the effect is the same as kParallel.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleAngVecVec;
// Create vector
vec1.x = 1.;
vec1.y = 2.;
vec1.z = 3.;
vec2.x = -1.;
vec2.y = -3.;
vec2.z = -2.;
refvec.x = 0.;
refvec.y = 0.;
refvec.z = 1.;
// Create rigid body
// Create a 3D angular constraint
AMCAX::GCS::Status status = gcsSystem.Create3dAngVecVec(handleAngVecVec, body1, body2, vec1, vec2, vecSence, angle, body3, refvec);
// Solve the constraint system
gcsSystem.Solve();
// Get updated vector
AMCAX::GCS::Vector3d vec1_update = gcsSystem.UpdateVector3dPosition(body1, vec1);
AMCAX::GCS::Vector3d vec2_update = gcsSystem.UpdateVector3dPosition(body2, vec2);
Status Create3dAngVecVec(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Vector3d &vector1, const Vector3d &vector2, VecSense vecSense, double a, const GCSWRigidBody &body3, const Vector3d &vector3)
Create a 3D angular constraint.
Vector3d UpdateVector3dPosition(const GCSWRigidBody &body, const Vector3d &vector)
Update the vector based on the transformation of the rigid body.

If the angle is set to AMCAX::Constants::pi, parallel constraint will be achieved. When VecSense is set to kCodirectional, the angle between the two vectors is 0°. When VecSense is set to kOpposed, the angle between the two vectors is 180°.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleAngVecVec;
// Create vector
vec1.x = 1.;
vec1.y = 2.;
vec1.z = 3.;
vec2.x = -1.;
vec2.y = -3.;
vec2.z = -2.;
refvec.x = 0.;
refvec.y = 0.;
refvec.z = 1.;
// Create rigid body
// Create a 3D angular constraint
double angle = AMCAX::Constants::pi;
AMCAX::GCS::Status status = gcsSystem.Create3dAngVecVec(handleAngVecVec, body1, body2, vec1, vec2, vecSence, angle, body3, refvec);
// Solve the constraint system
csSystem.Solve();
// Get updated vector
AMCAX::GCS::Vector3d vec1_update = gcsSystem.UpdateVector3dPosition(body1, vec1);
AMCAX::GCS::Vector3d vec2_update = gcsSystem.UpdateVector3dPosition(body2, vec2);
constexpr double pi
Mathematical constant Pi, ratio of a circle's circumference to its diameter.
Definition Constants.hpp:42

Symmetric Constraint

Currently, it supports creating a constraint for two points to be symmetric with respect to a plane. After this constraint is applied, the distances from these two points to the plane will be equal.

// Create constraint handle
// Create point
p1.x = 0.;
p1.y = 1.;
p1.z = 0.;
p2.x = 0.;
p2.y = 2.;
p2.z = 1.;
origin.x = 0.;
origin.y = 0.;
origin.z = 0.;
// Create vector
vec.x = 1.;
vec.y = 0.;
vec.z = 0.;
// Create plane
plane.origin = origin;
plane.normal = vec;
// Create rigid body
// Create a 3D symmetric constraint between two points about one fixed plane
AMCAX::GCS::Status status = gcsSystem.Create3dSymmPtPt(handleSymmPtPt, body1, body2, body3, p1, p2, plane);
// Solve the constraint system
gcsSystem.Solve();
// Get the updated point
AMCAX::GCS::Point3d p1_update = gcsSystem.UpdatePoint3dPosition(body1, p1);
AMCAX::GCS::Point3d p2_update = gcsSystem.UpdatePoint3dPosition(body2, p2);
Status Create3dSymmPtPt(GCSWConHandle &h, const GCSWRigidBody &body1, const GCSWRigidBody &body2, const Point3d &point1, const Point3d &point2, const Plane &plane)
Create a 3D symmetric constraint between two points about one fixed plane.

Erase

The Erase interface supports removing added objects and their associated constraints from the constraint system. It provides three overloaded forms for deleting geometric objects, rigid body objects, and constraint objects respectively.

Erase Geometric Object

Remove a geometric object from the system and automatically delete all its associated constraints.

// Create constraint handle
// Create a point in 2D
AMCAX::GCS::Point2d p{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint, p);
// Erase one geometry and all related constraints from the system
gcsSystem.Erase(handlePoint);
void Erase(GCSWVarGeomHandle &h)
Erase one geometry and all related constraints from the system.

Erase Rigid Body Object

Remove a rigid body object from the system and automatically delete all its associated constraints.

// Create rigid body
// Erase one rigid body and all related constraints from the system
gcsSystem.Erase(body1);

Erase Constraint

Remove a specified constraint object from the system.

// Create constraint handle
AMCAX::GCS::GCSWConHandle handleHorizontal;
// Create a point in 2D
AMCAX::GCS::Point2d p1{ 0., 0. };
AMCAX::GCS::Point2d p2{ 1., 2. };
gcsSystem.Create2dPoint(handlePoint1, p1);
gcsSystem.Create2dPoint(handlePoint2, p2);
// Create a 2D horizontal constraint between point/point
gcsSystem.Create2dHorizontal(handleHorizontal, handlePoint1, handlePoint2);
// Solve the constraint system
gcsSystem.Solve();
// Erase one constraint from the system
gcsSystem.Erase(handleHorizontal);