AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Geometry modeling

Construction of Curves and Surfaces

Abstract Curves and Surfaces

Curves

Lines

The AMCAX::MakeLine2 class is used to create a two-dimensional line.

AMCAX::Point2 point(1., 2.);
AMCAX::Direction2 dir(1., 0.);
// Construct a line
AMCAX::MakeLine2 ml(point, dir);
// Get the constructed line
AMCAX::Line2 l = ml.Value();
// Make a 2d edge
double p1 = 0.;
double p2 = 1.;
AMCAX::TopoShape line2d = AMCAX::MakeEdge2d(l, p1, p2);
Class of making a 2D edge.
Definition MakeEdge2d.hpp:24
Class of making 2D lines.
Definition MakeLine2.hpp:13
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15
LineS< 2 > Line2
2D line
Definition LineT.hpp:454
DirectionT< double, 2 > Direction2
2D direction
Definition DirectionT.hpp:563
PointT< double, 2 > Point2
2D point
Definition PointT.hpp:456

The AMCAX::MakeLine3 class is used to create a three-dimensional line.

AMCAX::Point3 point(1., 2., 3.);
AMCAX::Direction3 dir(1., 1., 1.);
// Construct a line
AMCAX::MakeLine3 ml(point, dir);
// Get the constructed line
AMCAX::Line3 l = ml.Value();
// Make a 3d edge
double p1 = 0.;
double p2 = 1.;
AMCAX::TopoShape line3d = AMCAX::MakeEdge(l, p1, p2);
Class of making an edge.
Definition MakeEdge.hpp:26
Class of making 3D lines.
Definition MakeLine3.hpp:13
LineS< 3 > Line3
3D line
Definition LineT.hpp:457
DirectionT< double, 3 > Direction3
3D direction
Definition DirectionT.hpp:566
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

Circles

The AMCAX::MakeCircle2 class is used to create a two-dimensional circle.

double radius = 2.;
// Make a 2D circle
AMCAX::MakeCircle2 mc(frame, radius);
// Get the constructed circle
AMCAX::Circle2 c = mc.Value();
// Make a 2d edge
Class of making 2D circles.
Definition MakeCircle2.hpp:13
FrameT< double, 2 > Frame2
2D frame
Definition FrameT.hpp:884
CircleS< 2 > Circle2
2D circle
Definition CircleT.hpp:184

The AMCAX::MakeCircle3 class is used to create a three-dimensional circle.

double radius = 3.;
// Make a 3D circle
AMCAX::MakeCircle3 mc(frame, radius);
// Get the constructed circle
AMCAX::Circle3 c = mc.Value();
// Make a 3d edge
Class of making 3D circles.
Definition MakeCircle3.hpp:15
CircleS< 3 > Circle3
3D circle
Definition CircleT.hpp:187
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:887

A circle can also be constructed from three points, as shown in the 2D example below.

// Define three points
AMCAX::Point2 A(1., 0.);
AMCAX::Point2 B(0., 1.);
AMCAX::Point2 C(0., -1.);
// Make a 2d circle
AMCAX::MakeCircle2 mc(A, B, C);
// Get the constructed circle
AMCAX::Circle2 c = mc.Value();
// Make a 2d edge

In two-dimensional space, if a point on the arc, the center of the circle, and the radius are known, the arc can be constructed as follows: first determine the radius from the center and the point on the arc, then calculate the endpoint of the arc through rotational transformation.

// Define points
AMCAX::Point2 A(1., 0.);
AMCAX::Point2 center(0., 0.);
// Calculate radius
double radius = center.Distance(A);
// Rotate point A around center by theta degree to get point B
double theta = 270.;
double thetaRad = theta * AMCAX::Constants::pi / 180.0;// Convert angle from degree to radian
transform.SetRotation(center, thetaRad);
AMCAX::Point2 B = A.Transformed(transform);
// Make a 2d circle
AMCAX::MakeCircle2 mc(center, radius);
// Get the constructed circle
AMCAX::Circle2 c = mc.Value();
// Make a 2d edge
AMCAX::TopoEdge circle2d = AMCAX::MakeEdge2d(c, A, B);
Class of edge.
Definition TopoEdge.hpp:12
void SetRotation(const PointT< OtherScalar, DIM > &point, const OtherScalar2 &angle) noexcept
Set the transformation as rotation around a point with an angle in 2D.
Definition TransformationT.hpp:138
constexpr double pi
Mathematical constant Pi, ratio of a circle's circumference to its diameter.
Definition Constants.hpp:42
TransformationT< double, 2 > Transformation2
2D transformation
Definition TransformationT.hpp:1112

Ellipses

The AMCAX::MakeEllipse2 class is used to create a two-dimensional ellipse.

double majorRadius = 2.;
double minorRadius = 1.;
// Make a 2d ellipse
AMCAX::MakeEllipse2 me(frame, majorRadius, minorRadius);
// Get the constructed ellipse
AMCAX::Ellipse2 e = me.Value();
// Make a 2d edge
Class of making 2D ellipses.
Definition MakeEllipse2.hpp:13
EllipseS< 2 > Ellipse2
2D ellipse
Definition EllipseT.hpp:264

The AMCAX::MakeEllipse3 class is used to create a three-dimensional ellipse.

double majorRadius = 4.;
double minorRadius = 2.;
// Make a 3d ellipse
AMCAX::MakeEllipse3 me(frame, majorRadius, minorRadius);
// Get the constructed ellipse
AMCAX::Ellipse3 e = me.Value();
// Make a 3d edge
Class of making 3D ellipses.
Definition MakeEllipse3.hpp:13
EllipseS< 3 > Ellipse3
3D ellipse
Definition EllipseT.hpp:267

Hyperbolas

The AMCAX::MakeHyperbola2 class is used to create a two-dimensional hyperbola.

double majorRadius = 2.;
double minorRadius = 1.;
// Make a 2d hyperbola
AMCAX::MakeHyperbola2 mh(frame, majorRadius, minorRadius);
// Get the constructed hyperbola
AMCAX::Hyperbola2 h = mh.Value();
// Make a 2d edge
double p1 = -1.;
double p2 = 1.;
AMCAX::TopoShape hyperbola2d = AMCAX::MakeEdge2d(h, p1, p2);
Class of making 2D hyperbolas.
Definition MakeHyperbola2.hpp:13
HyperbolaS< 2 > Hyperbola2
2D hyperbola
Definition HyperbolaT.hpp:327

The AMCAX::MakeHyperbola3 class is used to create a three-dimensional hyperbola.

double majorRadius = 4.;
double minorRadius = 2.;
// Make a 3d hyperbola
AMCAX::MakeHyperbola3 mh(frame, majorRadius, minorRadius);
// Get the constructed hyperbola
AMCAX::Hyperbola3 h = mh.Value();
// Make a 3d edge
double p1 = -1.;
double p2 = 1.;
AMCAX::TopoShape hyperbola3d = AMCAX::MakeEdge(h, p1, p2);
Class of making 3D hyperbolas.
Definition MakeHyperbola3.hpp:13
HyperbolaS< 3 > Hyperbola3
3D hyperbola
Definition HyperbolaT.hpp:330

Parabolas

The AMCAX::MakeParabola2 class is used to create a two-dimensional parabola.

double focal = 2.;
// Make a 2d parabola
AMCAX::MakeParabola2 mp(frame, focal);
// Get the constructed parabola
AMCAX::Parabola2 p = mp.Value();
// Make a 2d edge
double p1 = -1.;
double p2 = 1.;
AMCAX::TopoShape parabola2d = AMCAX::MakeEdge2d(p, p1, p2);
Class of making 2D parabolas.
Definition MakeParabola2.hpp:13
ParabolaS< 2 > Parabola2
2D parabola
Definition ParabolaT.hpp:204

The AMCAX::MakeParabola3 class is used to create a three-dimensional parabola.

double focal = 3.;
// Make a 3d parabola
AMCAX::MakeParabola3 mp(frame, focal);
// Get the constructed parabola
AMCAX::Parabola3 p = mp.Value();
// Make a 3d edge
double p1 = -1.;
double p2 = 1.;
AMCAX::TopoShape Parabola3d = AMCAX::MakeEdge(p, p1, p2);
Class of making 3D parabolas.
Definition MakeParabola3.hpp:13
ParabolaS< 3 > Parabola3
3D parabola
Definition ParabolaT.hpp:207

Surfaces

Planes

The AMCAX::MakePlane3 class is used to create a three-dimensional plane. Note: The plane is infinite, so to output to a file, use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

// Construct a plane
AMCAX::MakePlane3 mpl(frame);
// Get the constructed plane
AMCAX::Plane pl = mpl.Value();
// Make a face
double uMin = 0.;
double uMax = 2.;
double vMin = 0.;
double vMax = 2.;
AMCAX::TopoShape plane = AMCAX::MakeFace(pl, uMin, uMax, vMin, vMax);
Class of making a face.
Definition MakeFace.hpp:24
Class of making planes.
Definition MakePlane3.hpp:13
Class of Plane.
Definition Plane.hpp:13

Conical Surfaces

The AMCAX::MakeCone3 class is used to create a conical surface. Note: The conical surface is infinite along the axis direction, so to output to a file, use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

AMCAX::Point3 p1(0., 0., 0.);// The first point of the axis
AMCAX::Point3 p2(1., 2., 3.);// The second point of the axis
double r1 = 2.;// The radius of the section circle at the first point
double r2 = 1.;// The radius of the section circle at the second point
// Construct a cone
AMCAX::MakeCone3 mco(p1, p2, r1, r2);
// Get the constructed cone
AMCAX::Cone co = mco.Value();
// Make a face
double uMin = 0.;
double uMax = 2.;
double vMin = 0.;
double vMax = 2.;
AMCAX::TopoShape cone = AMCAX::MakeFace(co, uMin, uMax, vMin, vMax);
Class of cone.
Definition Cone.hpp:12
Class of making cones.
Definition MakeCone3.hpp:14

Cylindrical Surfaces

The AMCAX::MakeCylinder3 class is used to create a cylindrical surface. Note: The cylindrical surface is infinite along the axis direction, so to output to a file, use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

double radius = 2.;
// Construct a cylinder
AMCAX::MakeCylinder3 mcy(frame, radius);
// Get the constructed cylinder
AMCAX::Cylinder cy = mcy.Value();
// Make a face
double uMin = 0.;
double uMax = 2.;
double vMin = 0.;
double vMax = 2.;
AMCAX::TopoShape cylinder = AMCAX::MakeFace(cy, uMin, uMax, vMin, vMax);
Class of cylinder.
Definition Cylinder.hpp:12
Class of making cylinders.
Definition MakeCylinder3.hpp:14

Complete Geometric Curves and Surfaces

Curves

Lines

The AMCAX::MakeGeom2Line class is used to create a two-dimensional geometric line.

AMCAX::Point2 point(0.0, 0.0);
AMCAX::Direction2 dir(1.0, 0.0);
// Construct a geometric line
AMCAX::MakeGeom2Line mgl(point, dir);
// Get the constructed line
std::shared_ptr<AMCAX::Geom2Line> geomline2d = mgl.Value();
// Make a 2d edge
double p1 = 0.;
double p2 = 1.;
AMCAX::TopoShape line2d = AMCAX::MakeEdge2d(geomline2d, p1, p2);
Class of making 2D geometric lines.
Definition MakeGeom2Line.hpp:13

The AMCAX::MakeGeom3Line class is used to create a three-dimensional geometric line.

AMCAX::Point3 point(0.0, 0.0, 1.0);
AMCAX::Direction3 dir(1.0, 2.0, 3.0);
// Construct a geometric line
AMCAX::MakeGeom3Line mgl(point, dir);
// Get the constructed line
std::shared_ptr<AMCAX::Geom3Line> geomline3d = mgl.Value();
// Make a 3d edge
double p1 = 0.;
double p2 = 1.;
AMCAX::TopoShape line3d = AMCAX::MakeEdge(geomline3d, p1, p2);
Class of making 3D geometric lines.
Definition MakeGeom3Line.hpp:15

Circles

The AMCAX::MakeGeom2Circle class is used to create a two-dimensional geometric circle.

double radius = 3.;
// Construct a geometric circle
AMCAX::MakeGeom2Circle mgc(frame, radius);
// Get the constructed circle
std::shared_ptr<AMCAX::Geom2Circle> geomcircle2d = mgc.Value();
// Make a 2d edge
AMCAX::TopoShape circle2d = AMCAX::MakeEdge2d(geomcircle2d);
Class of making 2D geometric circles.
Definition MakeGeom2Circle.hpp:13

The AMCAX::MakeGeom3Circle class is used to create a three-dimensional geometric circle.

double radius = 2.;
// Construct a geometric circle
AMCAX::MakeGeom3Circle mgc(frame, radius);
// Get the constructed circle
std::shared_ptr<AMCAX::Geom3Circle> geomcircle3d = mgc.Value();
// Make a 3d edge
AMCAX::TopoShape circle3d = AMCAX::MakeEdge(geomcircle3d);
Class of making 3D geometric circles.
Definition MakeGeom3Circle.hpp:13

Ellipses

The AMCAX::MakeGeom2Ellipse class is used to create a two-dimensional geometric ellipse.

double majorRadius = 2.;
double minorRadius = 1.;
// Construct a geometric ellipse
AMCAX::MakeGeom2Ellipse mge(frame, majorRadius, minorRadius);
// Get the constructed ellipse
std::shared_ptr<AMCAX::Geom2Ellipse> geomellipse2d = mge.Value();
// Make a 2d edge
AMCAX::TopoShape ellipse2d = AMCAX::MakeEdge2d(geomellipse2d);
Class of making 2D geometric ellipses.
Definition MakeGeom2Ellipse.hpp:13

The AMCAX::MakeGeom3Ellipse class is used to create a three-dimensional geometric ellipse.

double majorRadius = 4.;
double minorRadius = 2.;
// Construct a geometric ellipse
AMCAX::MakeGeom3Ellipse mge(frame, majorRadius, minorRadius);
// Get the constructed ellipse
std::shared_ptr<AMCAX::Geom3Ellipse> geomellipse3d = mge.Value();
// Make a 3d edge
AMCAX::TopoShape ellipse3d = AMCAX::MakeEdge(geomellipse3d);
Class of making 3D geometric ellipses.
Definition MakeGeom3Ellipse.hpp:13

Hyperbolas

The AMCAX::MakeGeom2Hyperbola class is used to create a two-dimensional geometric hyperbola.

double majorRadius = 4.;
double minorRadius = 2.;
// Construct a geometric hyperbola
AMCAX::MakeGeom2Hyperbola mgh(frame, majorRadius, minorRadius);
// Get the constructed hyperbola
std::shared_ptr<AMCAX::Geom2Hyperbola> geomhyperbola2d = mgh.Value();
// Make a 2d edge
double p1 = -1.;
double p2 = 1.;
AMCAX::TopoShape hyperbola2d = AMCAX::MakeEdge2d(geomhyperbola2d, p1, p2);
Class of making 2D geometric hyperbolas.
Definition MakeGeom2Hyperbola.hpp:13

The AMCAX::MakeGeom3Hyperbola class is used to create a three-dimensional geometric hyperbola.

double majorRadius = 2.;
double minorRadius = 1.;
// Construct a geometric hyperbola
AMCAX::MakeGeom3Hyperbola mgh(frame, majorRadius, minorRadius);
// Get the constructed hyperbola
std::shared_ptr<AMCAX::Geom3Hyperbola> geomhyperbola3d = mgh.Value();
// Make a 3d edge
double p1 = -1.;
double p2 = 1.;
AMCAX::TopoShape hyperbola3d = AMCAX::MakeEdge(geomhyperbola3d, p1, p2);
Class of making 3D geometric hyperbolas.
Definition MakeGeom3Hyperbola.hpp:13

Parabolas

The AMCAX::MakeGeom2Parabola class is used to create a two-dimensional geometric parabola.

double focal = 2.;
// Construct a geometric parabola
AMCAX::MakeGeom2Parabola mgp(frame, focal);
// Get the constructed parabola
std::shared_ptr<AMCAX::Geom2Parabola> geomparabola2d = mgp.Value();
// Make a 2d edge
double p1 = -3.;
double p2 = 3.;
AMCAX::TopoShape parabola2d = AMCAX::MakeEdge2d(geomparabola2d, p1, p2);
Class of making 2D geometric parabolas.
Definition MakeGeom2Parabola.hpp:13

The AMCAX::MakeGeom3Parabola class is used to create a three-dimensional geometric parabola.

double focal = 4.;
// Construct a geometric parabola
AMCAX::MakeGeom3Parabola mgp(frame, focal);
// Get the constructed parabola
std::shared_ptr<AMCAX::Geom3Parabola> geomparabola3d = mgp.Value();
// Make a 3d edge
double p1 = -3.;
double p2 = 3.;
AMCAX::TopoShape parabola3d = AMCAX::MakeEdge(geomparabola3d, p1, p2);
Class of making 3D geometric parabolas.
Definition MakeGeom3Parabola.hpp:13

Surfaces

Planes

The AMCAX::MakeGeom3Plane class is used to create a geometric plane. Note: The plane is infinite, so to output to a file, use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

AMCAX::Point3 point(0.0, 0.0, 1.0);
AMCAX::Direction3 dir(1., 2., 3.);
// Construct a geometric plane
AMCAX::MakeGeom3Plane mgp(point, dir);
// Get the constructed plane
std::shared_ptr<AMCAX::Geom3Plane> geomplane = mgp.Value();
// Make a face
double uMin = -1.;
double uMax = 1.;
double vMin = -1.;
double vMax = 1.;
AMCAX::TopoShape plane = AMCAX::MakeFace(geomplane, uMin, uMax, vMin, vMax, AMCAX::Precision::Confusion());
Class of making geometric planes.
Definition MakeGeom3Plane.hpp:13
static constexpr double Confusion() noexcept
Get the confusion tolerance.
Definition Precision.hpp:122

Conical Surfaces

The AMCAX::MakeGeom3ConicalSurface class is used to create a geometric conical surface. Note: The conical surface is infinite along the axis direction, so to output to a file, use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

double radius = 2.;
// Construct a geometric conical surface
AMCAX::MakeGeom3ConicalSurface mgc(frame, radius, angle);
// Get the constructed conical surface
std::shared_ptr<AMCAX::Geom3ConicalSurface> geomconicalsurface = mgc.Value();
// Make a face
double uMin = 0.;
double uMax = 2 * AMCAX::Constants::pi * radius;
double vMin = 0.;
double vMax = 100.;
AMCAX::TopoShape conicalsurface = AMCAX::MakeFace(geomconicalsurface, uMin, uMax, vMin, vMax, AMCAX::Precision::Confusion());
Class of making geometric conical surfaces.
Definition MakeGeom3ConicalSurface.hpp:13
constexpr double quarter_pi
pi/4
Definition Constants.hpp:58

Cylindrical Surfaces

The AMCAX::MakeGeom3CylindricalSurface class is used to create a geometric cylindrical surface. Note: The cylindrical surface is infinite along the axis direction, so to output to a file, use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

double radius = 2.;
// Construct a geometric cylindrical surface
// Get the constructed cylindrical surface
std::shared_ptr<AMCAX::Geom3CylindricalSurface> geomcylindricalsurface = mgcy.Value();
// Make a face
double uMin = 0.;
double uMax = 2 * AMCAX::Constants::pi * radius;
double vMin = 0.;
double vMax = 3.;
AMCAX::TopoShape cylindricalsurface = AMCAX::MakeFace(geomcylindricalsurface, uMin, uMax, vMin, vMax, AMCAX::Precision::Confusion());
Class of making geometric cylindrical surfaces.
Definition MakeGeom3CylindricalSurface.hpp:14

Parameter Domain Trimmed Curves and Surfaces

Curves

Line Segments

The AMCAX::MakeSegment2d class is used to create a two-dimensional line segment.

AMCAX::Point2 p1(0., 0.);
AMCAX::Point2 p2(1., 3.);
// Construct a line segment
AMCAX::MakeSegment2d ms2d(p1, p2);
// Get the constructed line segment
std::shared_ptr<AMCAX::Geom2TrimmedCurve> s2d = ms2d.Value();
// Make a 2d edge
Class of making 2D line segments.
Definition MakeSegment2d.hpp:17

The AMCAX::MakeSegment class is used to create a three-dimensional line segment.

AMCAX::Point3 p1(0., 0., 0.);
AMCAX::Point3 p2(1., 2., 3.);
// Construct a line segment
AMCAX::MakeSegment ms3d(p1, p2);
// Get the constructed line segment
std::shared_ptr<AMCAX::Geom3TrimmedCurve> s3d = ms3d.Value();
// Make a 3d edge
Class of making 3D line segments.
Definition MakeSegment.hpp:17

Circular Arcs

The AMCAX::MakeArcOfCircle2d class is used to create a two-dimensional circular arc.

double radius = 2.;
AMCAX::Circle2 c(frame, radius);
// Construct an arc of circle
double alpha1 = 0.;
double alpha2 = 2.;
AMCAX::MakeArcOfCircle2d marc(c, alpha1, alpha2, true);
// Get the constructed arc of circle
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofcircle = marc.Value();
// Make a 2d edge
AMCAX::TopoShape arcofcircle2d = AMCAX::MakeEdge2d(arcofcircle);
Class of making arcs of 2D circle.
Definition MakeArcOfCircle2d.hpp:17

The AMCAX::MakeArcOfCircle class is used to create a three-dimensional circular arc.

double radius = 3.;
AMCAX::Circle3 c(frame, radius);
// Construct an arc of circle
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfCircle marc(c, alpha1, alpha2, true);
// Get the constructed arc of circle
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofcircle = marc.Value();
// Make a 2d edge
AMCAX::TopoShape arcofcircle3d = AMCAX::MakeEdge(arcofcircle);
Class of making arcs of 3D circle.
Definition MakeArcOfCircle.hpp:17

Elliptical Arcs

The AMCAX::MakeArcOfEllipse2d class is used to create a two-dimensional elliptical arc.

double majorRadius = 2.;
double minorRadius = 1.;
AMCAX::Ellipse2 e(frame, majorRadius, minorRadius);
// Construct an arc of ellipse
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfEllipse2d marce(e, alpha1, alpha2, true);
// Get the constructed arc of ellipse
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofellipse = marce.Value();
// Make a 2d edge
AMCAX::TopoShape arcofellipse2d = AMCAX::MakeEdge2d(arcofellipse);
Class of making arcs of 2D ellipse.
Definition MakeArcOfEllipse2d.hpp:17

The AMCAX::MakeArcOfEllipse class is used to create a three-dimensional elliptical arc.

double majorRadius = 3.;
double minorRadius = 2.;
AMCAX::Ellipse3 e(frame, majorRadius, minorRadius);
// Construct an arc of ellipse
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfEllipse marce(e, alpha1, alpha2, true);
// Get the constructed arc of ellipse
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofellipse = marce.Value();
// Make a 3d edge
AMCAX::TopoShape arcofellipse3d = AMCAX::MakeEdge(arcofellipse);
Class of making arcs of 3D ellipse.
Definition MakeArcOfEllipse.hpp:17

Hyperbolic Arcs

The AMCAX::MakeArcOfHyperbola2d class is used to create a two-dimensional hyperbolic arc.

double majorRadius = 2.;
double minorRadius = 1.;
AMCAX::Hyperbola2 h(frame, majorRadius, minorRadius);
// Construct an arc of hyperbola
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfHyperbola2d march(h, alpha1, alpha2, true);
// Get the constructed arc of hyperbola
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofhyperbola = march.Value();
// Make a 2d edge
AMCAX::TopoShape arcofhyperbola2d = AMCAX::MakeEdge2d(arcofhyperbola);
Class of making arcs of 2D hyperbola.
Definition MakeArcOfHyperbola2d.hpp:17

The AMCAX::MakeArcOfHyperbola class is used to create a three-dimensional hyperbolic arc.

double majorRadius = 3.;
double minorRadius = 2.;
AMCAX::Hyperbola3 h(frame, majorRadius, minorRadius);
// Construct an arc of hyperbola
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfHyperbola march(h, alpha1, alpha2, true);
// Get the constructed arc of hyperbola
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofhyperbola = march.Value();
// Make a 3d edge
AMCAX::TopoShape arcofhyperbola3d = AMCAX::MakeEdge(arcofhyperbola);
Class of making arcs of 3D hyperbola.
Definition MakeArcOfHyperbola.hpp:17

Parabolic Arcs

The AMCAX::MakeArcOfParabola2d class is used to create a two-dimensional parabolic arc.

double focal = 2.;
AMCAX::Parabola2 p(frame, focal);
// Construct an arc of parabola
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfParabola2d marcp(p, alpha1, alpha2, true);
// Get the constructed arc of parabola
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofparabola = marcp.Value();
// Make a 2d edge
AMCAX::TopoShape arcofparabola2d = AMCAX::MakeEdge2d(arcofparabola);
Class of making arcs of 2D parabola.
Definition MakeArcOfParabola2d.hpp:17

The AMCAX::MakeArcOfParabola class is used to create a three-dimensional parabolic arc.

double focal = 3.;
AMCAX::Parabola3 p(frame, focal);
// Construct an arc of parabola
double alpha1 = 0.;// The first parameter
double alpha2 = 2.;// The last parameter
AMCAX::MakeArcOfParabola marcp(p, alpha1, alpha2, true);
// Get the constructed arc of parabola
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofparabola = marcp.Value();
// Make a 3d edge
AMCAX::TopoShape arcofparabola3d = AMCAX::MakeEdge(arcofparabola);
Class of making arcs of 3D parabola.
Definition MakeArcOfParabola.hpp:17

Surfaces

Trimmed Conical Surfaces

The AMCAX::MakeTrimmedCone class is used to create a trimmed conical surface.

AMCAX::Point3 p1(0., 0., 0.);// The first point of the axis
AMCAX::Point3 p2(0., 0., 1.);// The second point of the axis
double r1 = 2.;// The radius of the section circle at the first point
double r2 = 1.;// The radius of the section circle at the second point
// Construct a trimmed cone
AMCAX::MakeTrimmedCone mtc(p1, p2, r1, r2);
// Get the constructed trimmed cone
std::shared_ptr<AMCAX::Geom3TrimmedSurface> tc = mtc.Value();
// Make a face
Class of making trimmed cones.
Definition MakeTrimmedCone.hpp:17

Trimmed Cylindrical Surfaces

The AMCAX::MakeTrimmedCylinder class is used to create a trimmed cylindrical surface.

AMCAX::Point3 p1(0., 0., 0.);// The first point on the axis
AMCAX::Point3 p2(0., 0., 2.);// The second point on the axis
AMCAX::Point3 p3(2., 0., 0.);// The point on the cylinder
// Construct a trimmed cylinder
// Get the constructed trimmed cylinder
std::shared_ptr<AMCAX::Geom3TrimmedSurface> tc = mtc.Value();
// Make a face
Class of making trimmed cylinders.
Definition MakeTrimmedCylinder.hpp:17

Evaluation of Curves and Surfaces

Curves and surfaces can be evaluated using Value() or D0(). Taking a surface as an example:

AMCAX::Point3 p1(0., 0., 0.);// The first point on the axis
AMCAX::Point3 p2(0., 0., 2.);// The second point on the axis
AMCAX::Point3 p3(2., 0., 0.);// The point on the cylinder
// Construct a trimmed cylinder
// Get the constructed trimmed cylinder
std::shared_ptr<AMCAX::Geom3TrimmedSurface> tc = mtc.Value();
// Value
double u = 2., v = 0.9;
std::cout << tc->Value(u, v) << std::endl;// -0.832294 1.81859 0.9
// D0
tc->D0(u, v, p);
std::cout << p << std::endl;// -0.832294 1.81859 0.9

Creating Parametric Curves and Surfaces through Interpolation and Fitting

Interpolation Curves

Two-dimensional Interpolation Curves

The AMCAX::GeomAPIInterpolate2 class is used to compute two-dimensional interpolation curves.

// Define points
std::vector<AMCAX::Point2> points = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
// Compute a curve interpolating 2D points
AMCAX::GeomAPIInterpolate2 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
interpolate.Perform();
if (interpolate.IsDone())
{
// Get the interpolation curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
// Make a 2d edge
AMCAX::Point2 p1(0., 0.);// The first point
AMCAX::Point2 p2(4., 0.);// The second point
AMCAX::TopoShape interpolate2d = AMCAX::MakeEdge2d(curve2d, p1, p2);
}
else
std::cout << "error:interpolate failed" << std::endl;
Class of computing a curve interpolating 2D points.
Definition GeomAPIInterpolate2.hpp:18

Additionally, tangent vector constraints can be added during interpolation using AMCAX::GeomAPIInterpolate2::Load to control the shape of the generated curve. Tangent vectors for all points can be added as constraints, or only the start and end points' tangent vectors can be added.

Adding tangent vectors for all points as constraints:

// Define points
std::vector<AMCAX::Point2> points = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
// Compute a curve interpolating 2D points
AMCAX::GeomAPIInterpolate2 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
// The tangent vectors
std::vector<AMCAX::Vector2> tangents = {
AMCAX::Vector2(1.0, 0.0),
AMCAX::Vector2(0.0, 1.0),
AMCAX::Vector2(-1.0, 0.0),
AMCAX::Vector2(0.0, -1.0),
AMCAX::Vector2(1.0, 0.0)
};
std::vector<bool> tangentFlags = { true, true, true, true, true };
// Load the tangent vector at each point as constraints
interpolate.Load(tangents, tangentFlags, true);
interpolate.Perform();
if (interpolate.IsDone())
{
// Get the interpolation curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
// Make a 2d edge
AMCAX::Point2 p1(0., 0.);// The first point
AMCAX::Point2 p2(4., 0.);// The second point
AMCAX::TopoShape interpolate2d = AMCAX::MakeEdge2d(curve2d, p1, p2);
}
else
std::cout << "error:interpolate failed" << std::endl;
VectorT< double, 2 > Vector2
2D vector
Definition VectorT.hpp:704

Adding tangent vectors for start and end points as constraints:

// Define points
std::vector<AMCAX::Point2> points = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
// Compute a curve interpolating 2D points
AMCAX::GeomAPIInterpolate2 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
AMCAX::Vector2 initialTangent(1.0, 0.0);// The tangent vector at the start point
AMCAX::Vector2 finalTangent(0.0, -1.0);// The tangent vector at the end point
// Load the tangent vector at the start and end point as constraints
interpolate.Load(initialTangent, finalTangent, true);
interpolate.Perform();
if (interpolate.IsDone())
{
// Get the interpolation curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
// Make a 2d edge
AMCAX::Point2 p1(0., 0.);// The first point
AMCAX::Point2 p2(4., 0.);// The second point
AMCAX::TopoShape interpolate2d = AMCAX::MakeEdge2d(curve2d, p1, p2);
}
else
std::cout << "error:interpolate failed" << std::endl;

Three-dimensional Interpolation Curves

The AMCAX::GeomAPIInterpolate3 class is used to compute three-dimensional interpolation curves.

// Define points
std::vector<AMCAX::Point3> points = {
AMCAX::Point3(0.0, 0.0, 0.0),
AMCAX::Point3(1.0, 1.0, 1.0),
AMCAX::Point3(2.0, 0.0, 2.0),
AMCAX::Point3(3.0, -1.0, 3.0),
AMCAX::Point3(4.0, 0.0, 4.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
// Compute a curve interpolating 3D points
AMCAX::GeomAPIInterpolate3 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
interpolate.Perform();
if (interpolate.IsDone())
{
// Get the interpolation curve
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate.Curve();
// Make a 3d edge
AMCAX::Point3 p1(0., 0., 0.);// The first point
AMCAX::Point3 p2(4.0, 0.0, 4.0);// The second point
AMCAX::TopoShape interpolate3d = AMCAX::MakeEdge(curve3d, p1, p2);
}
else
std::cout << "error: interpolate failed" << std::endl;
Class of computing a curve interpolating 3D points.
Definition GeomAPIInterpolate3.hpp:18

Additionally, tangent vector constraints can be added during interpolation using AMCAX::GeomAPIInterpolate3::Load to control the shape of the generated curve. Tangent vectors for all points can be added as constraints, or only the start and end points' tangent vectors can be added.

Adding tangent vectors for all points as constraints:

// Define points
std::vector<AMCAX::Point3> points = {
AMCAX::Point3(0.0, 0.0, 0.0),
AMCAX::Point3(1.0, 1.0, 1.0),
AMCAX::Point3(2.0, 0.0, 2.0),
AMCAX::Point3(3.0, -1.0, 3.0),
AMCAX::Point3(4.0, 0.0, 4.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
// Compute a curve interpolating 3D points
AMCAX::GeomAPIInterpolate3 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
// The tangent vectors
std::vector<AMCAX::Vector3> tangents = {
AMCAX::Vector3(1.0, 0.0, 0.0),
AMCAX::Vector3(0.0, 1.0, 0.0),
AMCAX::Vector3(0.0, 0.0, 1.0),
AMCAX::Vector3(-1.0, 0.0, 0.0),
AMCAX::Vector3(0.0, -1.0, 0.0)
};
std::vector<bool> tangentFlags = { true, true, true, true, true };
// Load the tangent vector at each point as constraints
interpolate.Load(tangents, tangentFlags, true);
interpolate.Perform();
if (interpolate.IsDone())
{
// Get the interpolation curve
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate.Curve();
// Make a 3d edge
AMCAX::Point3 p1(0., 0., 0.);// The first point
AMCAX::Point3 p2(4.0, 0.0, 4.0);// The second point
AMCAX::TopoShape interpolate3d = AMCAX::MakeEdge(curve3d, p1, p2);
}
else
std::cout << "error: interpolate failed" << std::endl;
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Adding tangent vectors for start and end points as constraints:

// Define points
std::vector<AMCAX::Point3> points = {
AMCAX::Point3(0.0, 0.0, 0.0),
AMCAX::Point3(1.0, 1.0, 1.0),
AMCAX::Point3(2.0, 0.0, 2.0),
AMCAX::Point3(3.0, -1.0, 3.0),
AMCAX::Point3(4.0, 0.0, 4.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
// Compute a curve interpolating 3D points
AMCAX::GeomAPIInterpolate3 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
AMCAX::Vector3 initialTangent(1.0, 0.0, 0.0);// The tangent vector at the start point
AMCAX::Vector3 finalTangent(0.0, -1.0, 0.0);// The tangent vector at the end point
// Load the tangent vector at the start and end point as constraints
interpolate.Load(initialTangent, finalTangent, true);
interpolate.Perform();
if (interpolate.IsDone())
{
// Get the interpolation curve
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate.Curve();
// Make a 3d edge
AMCAX::Point3 p1(0., 0., 0.);// The first point
AMCAX::Point3 p2(4.0, 0.0, 4.0);// The second point
AMCAX::TopoShape interpolate3d = AMCAX::MakeEdge(curve3d, p1, p2);
}
else
std::cout << "error: interpolate failed" << std::endl;

Fitting Curves

Two-dimensional Fitting Curves

The AMCAX::GeomAPIPointsToBSpline2 class is used to compute two-dimensional fitting curves.

// Define points
std::vector<AMCAX::Point2> points = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin = 3;// The minimal degree of B spline curve
int degMax = 8;// The maximal degree of B spline curve
AMCAX::ContinuityType continuity = AMCAX::ContinuityType::C2;
double tol = 1e-3;
// Compute a 2D B spline curve approximating 2D points
AMCAX::GeomAPIPointsToBSpline2 ptb(points, parameters, degMin, degMax, continuity, tol);
if (ptb.IsDone())
{
// Get the result curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve = ptb.Curve();
// Make a 2d edge
AMCAX::Point2 p1(0.0, 0.0);
AMCAX::Point2 p2(4.0, 0.0);
AMCAX::TopoShape BSplineCurve2d = AMCAX::MakeEdge2d(BSplineCurve, p1, p2);
}
else
std::cout << "error: Bspline curve fitting failed" << std::endl;
Class of computing a 2D B spline curve approximating 2D points.
Definition GeomAPIPointsToBSpline2.hpp:19
ContinuityType
Type of continuity.
Definition GeometryMacros.hpp:84

Additionally, a B-spline curve can be fitted based on the starting point's x-coordinate, constant increment of x-coordinate, and a set of y-coordinate points. In the following example, the starting point's x-coordinate is 0.0, the constant increment of x-coordinate is 1.0, and the number of y-coordinate points is 5, so the ending point's x-coordinate can be inferred as 4.0.

// Define points
std::vector<AMCAX::Point2> points = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin = 3;// The minimal degree of B spline curve
int degMax = 8;// The maximal degree of B spline curve
AMCAX::ContinuityType continuity = AMCAX::ContinuityType::C2;
double tol = 1e-6;
std::vector<double> yValues = { 0.0, 1.0, 0.5, 2.0, 1.5 };// The y coordinates of points
double x0 = 0.;// The x coordinate of the first point
double dx = 1.;// The incremental value of x coordinate
// Compute a 2D B spline curve approximating 2D points
AMCAX::GeomAPIPointsToBSpline2 ptb(yValues, x0, dx, degMin, degMax, continuity, tol);
if (ptb.IsDone())
{
// Get the result curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve = ptb.Curve();
// Make a 2d edge
AMCAX::Point2 p1(0.0, 0.0);
AMCAX::Point2 p2(4.0, 0.0);
AMCAX::TopoShape BSplineCurve2d = AMCAX::MakeEdge2d(BSplineCurve, p1, p2);
}
else
std::cout << "error: Bspline curve fitting failed" << std::endl;

Three-dimensional Fitting Curves

The AMCAX::GeomAPIPointsToBSpline3 class is used to compute three-dimensional fitting curves.

// Define points
std::vector<AMCAX::Point3> points = {
AMCAX::Point3(0.0, 0.0, 0.0),
AMCAX::Point3(1.0, 1.0, 1.0),
AMCAX::Point3(2.0, 0.0, 2.0),
AMCAX::Point3(3.0, -1.0, 3.0),
AMCAX::Point3(4.0, 0.0, 4.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin = 3;// The minimal degree of B spline curve
int degMax = 8;// The maximal degree of B spline curve
AMCAX::ContinuityType continuity = AMCAX::ContinuityType::C2;
double tol = 1e-3;
// Compute a 3D B spline curve approximating 2D points
AMCAX::GeomAPIPointsToBSpline3 ptb(points, parameters, degMin, degMax, continuity, tol);
if (ptb.IsDone()) {
// Get the result curve
std::shared_ptr<AMCAX::Geom3BSplineCurve> BSplineCurve = ptb.Curve();
// Make a 3d edge
AMCAX::Point3 p1(0.0, 0.0, 0.0);
AMCAX::Point3 p2(4.0, 0.0, 4.0);
AMCAX::TopoShape BSplineCurve3d = AMCAX::MakeEdge(BSplineCurve, p1, p2);
}
else
std::cout << "error: Bspline curve fitting failed" << std::endl;
Class of computing a 3D B spline curve approximating 3D points.
Definition GeomAPIPointsToBSpline3.hpp:19

Fitting Surfaces

AMCAX::GeomAPIPointsToBSplineSurface is used to compute fitting surfaces.

// Define points
controls(0, 0) = AMCAX::Point3(-6., -6., 0.);
controls(0, 1) = AMCAX::Point3(-3., -6., -2.);
controls(0, 2) = AMCAX::Point3(3., -6., -2.);
controls(0, 3) = AMCAX::Point3(6., -6., 0.);
controls(1, 0) = AMCAX::Point3(-6., -3., -2.);
controls(1, 1) = AMCAX::Point3(-3., -3., -2.);
controls(1, 2) = AMCAX::Point3(3., -3., 2.);
controls(1, 3) = AMCAX::Point3(6., -3., 2.);
controls(2, 0) = AMCAX::Point3(-6., 3., -2.);
controls(2, 1) = AMCAX::Point3(-3., 3., 2.);
controls(2, 2) = AMCAX::Point3(3., 3., -2.);
controls(2, 3) = AMCAX::Point3(6., 3., 2.);
controls(3, 0) = AMCAX::Point3(-6., 6., 0.);
controls(3, 1) = AMCAX::Point3(-3., 6., 2.);
controls(3, 2) = AMCAX::Point3(3., 6., 2.);
controls(3, 3) = AMCAX::Point3(6., 6., 0.);
int degMin = 3;// The minimal degree of B spline curve
int degMax = 8;// The maximal degree of B spline curve
AMCAX::ContinuityType continuity = AMCAX::ContinuityType::C2;
double tol = 1e-3;
// Compute a B spline surface approximating points
AMCAX::GeomAPIPointsToBSplineSurface ptbs(controls, degMin, degMax, continuity, tol);
if (ptbs.IsDone())
{
// Get the result surface
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsurface = ptbs.Surface();
// Make a face
}
else
std::cout << "error: Bspline surface fitting failed" << std::endl;
Template class of two dimensional array.
Definition Array2.hpp:17
Class of computing a B spline surface approximating points.
Definition GeomAPIPointsToBSplineSurface.hpp:19

Additionally, a B-spline surface can be fitted based on the starting point's x and y coordinates, constant increments of x and y coordinates, and a set of z-coordinate points.

AMCAX::Array2<double> zPoints(3, 3);// The z coordinates of points
zPoints(0, 0) = 0.0; zPoints(0, 1) = 1.0; zPoints(0, 2) = 0.0;
zPoints(1, 0) = 1.0; zPoints(1, 1) = 2.0; zPoints(1, 2) = 1.0;
zPoints(2, 0) = 0.0; zPoints(2, 1) = 1.0; zPoints(2, 2) = 0.0;
double x0 = 0.0;// The x coordinate of the first point
double dx = 1.0;// The incremental value of x coordinate
double y0 = 0.0;// The y coordinate of the first point
double dy = 1.0;// The incremental value of y coordinate
int degMin = 3;// The minimal degree of B spline curve
int degMax = 8;// The maximal degree of B spline curve
AMCAX::ContinuityType continuity = AMCAX::ContinuityType::C2;
double tol = 1e-3;
// Compute a B spline surface approximating points
AMCAX::GeomAPIPointsToBSplineSurface ptbs(zPoints, x0, dx, y0, dy, degMin, degMax, continuity, tol);
if (ptbs.IsDone())
{
// Get the result surface
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsurface = ptbs.Surface();
// Make a face
}
else
std::cout << "error: Bspline surface fitting failed" << std::endl;

Intersections of 2D Curves, Curve-Surface Intersections, and Surface-Surface Intersections

2D Curve Intersections

The AMCAX::GeomAPIIntCurveCurve2 class is used to compute intersections between two 2D curves, which may be intersection points or segments.
Example with intersection points as results:

// Construct a B spline curve
std::vector<AMCAX::Point2> pts = {
AMCAX::Point2(0.0, 2.0),
AMCAX::Point2(1.0, 3.0),
AMCAX::Point2(2.0, 1.0),
AMCAX::Point2(3.0, 3.0),
AMCAX::Point2(4.0, 1.0),
AMCAX::Point2(5.0, 3.0),
AMCAX::Point2(6.0, 2.0)
};
std::vector<double> knots = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 };
std::vector<int> multiplicities = { 4, 1, 1, 1, 1, 4 };
int degree = 4;
auto bspline = std::make_shared<AMCAX::Geom2BSplineCurve>(pts, knots, multiplicities, degree);
// Construct a circle
AMCAX::Point2 point(3., 3.);
AMCAX::Direction2 dir_x(1., 0.);
AMCAX::Direction2 dir_y(0., 1.);
AMCAX::Frame2 frame(point, dir_x, dir_y);
double radius = 1.;
auto circle = std::make_shared<AMCAX::Geom2Circle>(frame, radius);
// Compute intersection points for two 2D curves
std::cout << cc.NPoints() << std::endl;// 2
std::cout << cc.Point(0) << std::endl;// 2.59489 2.08573
std::cout << cc.Point(1) << std::endl;// 3.40511 2.08573
std::cout << cc.ParamOnCurve1(0) << std::endl;// 0.420769
std::cout << cc.ParamOnCurve1(1) << std::endl;// 0.579231
std::cout << cc.ParamOnCurve2(0) << std::endl;// 4.29529
std::cout << cc.ParamOnCurve2(1) << std::endl;// 5.12949
Class of computing intersection points for two 2D curves.
Definition GeomAPIIntCurveCurve2.hpp:19

Example with intersection segments as results:

// Construct a line
AMCAX::Point2 point(0., 0.);
AMCAX::Direction2 dir(1., 0.);
auto line = std::make_shared<AMCAX::Geom2Line>(point, dir);
// Construct a trimmed line
double u1 = 0., u3 = 2.;// The lower bound of the parameter
double u2 = 3., u4 = 4.;// The upper bound of the parameter
auto trimline1 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line, u1, u2);
auto trimline2 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line, u3, u4);
// Compute intersection segments for two 2D curves
std::cout << cc.NSegments() << std::endl;//1
std::pair<double, double> paramOnCurve1;
std::pair<double, double> paramOnCurve2;
// Get the intersection segments at a given index
cc.Segment(0, paramOnCurve1, paramOnCurve2);
std::cout << paramOnCurve1.first << std::endl;// 2
std::cout << paramOnCurve1.second << std::endl;// 3
std::cout << paramOnCurve2.first << std::endl;// 2
std::cout << paramOnCurve2.second << std::endl;// 3

Additionally, AMCAX::GeomAPIIntCurveCurve2 can be used to determine if a 2D curve self-intersects and compute the number of self-intersection points.

// Construct a B spline curve
std::vector<AMCAX::Point2> pts = {
AMCAX::Point2(0.5, 0.5),
AMCAX::Point2(1.0, 3.0),
AMCAX::Point2(3.0, 1.0),
AMCAX::Point2(3.8,2.0),
AMCAX::Point2(2.5,3.5),
AMCAX::Point2(1.0,0.5),
AMCAX::Point2(0.3,2.0)
};
std::vector<double> knots = { 0.0, 0.25, 0.5,0.75,1.0 };
std::vector<int> multiplicities = { 4, 1, 1,1,4 };
int degree = 3;
auto bspline = std::make_shared<AMCAX::Geom2BSplineCurve>(pts, knots, multiplicities, degree);
// Compute intersection points
std::cout << cc.NPoints() << std::endl;// 2

Curve-Surface Intersections

AMCAX::GeomAPIIntCurveSurface is used to compute intersections between a curve and a surface, which may be intersection points or segments.
Example with intersection points as results:

// Construct a bezier curve
std::vector<AMCAX::Point3> pts = {
AMCAX::Point3(0.0, 0.0,0.0),
AMCAX::Point3(2.0, 2.0,2.0),
AMCAX::Point3(4.0, 3.0,5.0),
AMCAX::Point3(6.0,2.0,4.0)
};
auto bezier = std::make_shared<AMCAX::Geom3BezierCurve>(pts);
// Construct a cylindrical surface
double radius = 3.;
std::shared_ptr<AMCAX::Geom3CylindricalSurface> CylindricalSurface = std::make_shared<AMCAX::Geom3CylindricalSurface>(frame, radius);
// Construct a trimmed surface
double param1 = 0.;
double param2 = 5.;
bool uTrim = false;// trimmed along v direction
std::shared_ptr<AMCAX::Geom3TrimmedSurface> TrimmedSurface = std::make_shared<AMCAX::Geom3TrimmedSurface>(CylindricalSurface, param1, param2, uTrim);
// Compute intersection points for a curve and a surface
AMCAX::GeomAPIIntCurveSurface cs(bezier, TrimmedSurface);
cs.Perform(bezier, TrimmedSurface);
if (cs.IsDone())
{
std::cout << cs.NPoints() << std::endl;// 1
// Get the parameters of the intersection point at a given index
double u = 0., v = 0., w = 0.;
cs.Parameters(0, u, v, w);
std::cout << u << std::endl;// 0.660279
std::cout << v << std::endl;// 2.52939
std::cout << w << std::endl;// 0.394911
std::cout << cs.Point(0) << std::endl;// 2.36946 1.84001 2.52939
}
Class of computing intersection points for a curve and a surface.
Definition GeomAPIIntCurveSurface.hpp:20

Surface-Surface Intersections

The AMCAX::GeomAPIIntSurfaceSurface class is used to compute intersections between surfaces.

// Construct a cylindrical surface
double radius = 3.;
std::shared_ptr<AMCAX::Geom3CylindricalSurface> CylindricalSurface = std::make_shared<AMCAX::Geom3CylindricalSurface>(frame, radius);
// Construct a trimmed surface
double param1 = 0.;
double param2 = 5.;
bool uTrim = false;// trimmed along v direction
std::shared_ptr<AMCAX::Geom3TrimmedSurface> trimcylinder = std::make_shared<AMCAX::Geom3TrimmedSurface>(CylindricalSurface, param1, param2, uTrim);
// Construct a plane
auto plane = std::make_shared<AMCAX::Geom3Plane>(frame);
// Construct a trimmed surface
double u1 = 0.;// The lower bound of u parameter
double u2 = 5.;// The upper bound of u parameter
double v1 = 0.;// The lower bound of v parameter
double v2 = 5.;// The upper bound of v parameter
std::shared_ptr<AMCAX::Geom3TrimmedSurface> trimplane = std::make_shared<AMCAX::Geom3TrimmedSurface>(plane, u1, u2, v1, v2);
// Compute intersection curves for two surfaces
ss.Perform(trimcylinder, trimplane, AMCAX::Precision::Confusion());
if (ss.IsDone())
{
std::cout << ss.NLines() << std::endl;// 1
// Get the intersection curve at a given index
std::shared_ptr<AMCAX::Geom3Curve> line = ss.Line(0);
// Make a edge
AMCAX::TopoShape intersection = AMCAX::MakeEdge(line);
}
Class of computing intersection curves for two surfaces.
Definition GeomAPIIntSurfaceSurface.hpp:20

Computing Extremal Values Between Geometric Objects

Extremal Values Between 2D Curves

The AMCAX::GeomAPIExtremaCurveCurve2class is used to compute minimum distance points between two 2D curves. For input curves, first use AMCAX::GeomAPIExtremaCurveCurve2::IsParallelto determine if the curves are parallel. If they are parallel, extremal points do not exist, NExtrema()returns 1, and attempting to get the minimum distance or nearest points will throw an OutOfRangeexception. If the curves are not parallel, information about extremal points can be obtained as shown below:

// Construct the first B spline curve
std::vector<AMCAX::Point2> pts1 = {
AMCAX::Point2(0.0, 2.0),
AMCAX::Point2(1.0, 3.0),
AMCAX::Point2(2.0, 1.0),
AMCAX::Point2(3.0, 3.0),
AMCAX::Point2(4.0, 1.0),
AMCAX::Point2(5.0, 3.0),
AMCAX::Point2(6.0, 2.0)
};
std::vector<double> knots1 = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 };
std::vector<int> mults1 = { 4, 1, 1, 1, 1, 4 };
int degree = 4;
auto bspline1 = std::make_shared< AMCAX::Geom2BSplineCurve>(pts1, knots1, mults1, degree);
// Construct the second B spline curve
std::vector<AMCAX::Point2> pts2;
for (const auto& pt : pts1) {
pts2.push_back(AMCAX::Point2(pt.X(), -pt.Y()));
}
auto bspline2 = std::make_shared<AMCAX::Geom2BSplineCurve>(pts2, knots1, mults1, degree);
// Compute extremal points for two 2D curves
double u1min = bspline1->FirstParameter();// The first parameter of the first curve
double u1max = bspline1->LastParameter();// The last parameter of the first curve
double u2min = bspline2->FirstParameter();// The first parameter of the second curve
double u2max = bspline2->LastParameter();// The last parameter of the second curve
AMCAX::GeomAPIExtremaCurveCurve2 excc(bspline1, bspline2, u1min, u1max, u2min, u2max);
if (excc.IsParallel()) // parallel case, no extremal points, only extremal distance
{
double dist = excc.LowerDistance(); // minimum distance
}
else
{
if (excc.NExtrema() > 0)
{
// Get the nearest points
AMCAX::Point2 p1;// The nearest point on the first curve
AMCAX::Point2 p2;// The nearest point on the second curve
excc.NearestPoints(p1, p2);
std::cout << "p1:" << p1 << std::endl;// p1:2.07541 1.9023
std::cout << "p2:" << p2 << std::endl;// p2:2.07541 -1.9023
// Get the parameters of the nearest points
double param1, param2;
excc.LowerDistanceParameters(param1, param2);
std::cout << "param1:" << param1 << std::endl;// param1:0.32501
std::cout << "param2:" << param2 << std::endl;// param2:0.32501
// Get the distance of the nearest points
double nearestdist = excc.LowerDistance();
std::cout << "nearestdist:" << nearestdist << std::endl;// nearestdist:3.8046
}
for (int i = 0; i < excc.NExtrema(); i++)
{
std::cout << "the" << " " << i << " " << "extremal point:" << std::endl;
// Get the extremal points at a given index
AMCAX::Point2 p1;// The extremal point on the first curve
AMCAX::Point2 p2;// The extremal point on the second curve
excc.Points(i, p1, p2);
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
// Get the parameters of the extrema at a given index
double param1;// The parameter of the extremal point on the first curve
double param2;// The parameter of the extremal point on the second curve
excc.Parameters(i, param1, param2);
std::cout << "param1: " << param1 << std::endl;
std::cout << "param2: " << param2 << std::endl;
// Get the extremal distance at a given index
double dist = excc.Distance(i);
std::cout << "dist: " << dist << std::endl;
std::cout << std::endl;
}
}
Class of computing extremal points for two 2D curves.
Definition GeomAPIExtremaCurveCurve2.hpp:20
auto Distance(const PointT< OtherScalar, DIM > &other) const noexcept
Compute the Euclidean distance from the other point.
Definition PointT.hpp:180

Extremal Values Between 3D Curves

The AMCAX::GeomAPIExtremaCurveCurve3class is used to compute minimum distance points between two 3D curves. For input curves, first use AMCAX::GeomAPIExtremaCurveCurve3::IsParallelto determine if the curves are parallel. If they are parallel, extremal points do not exist, NExtrema()returns 1, and attempting to get the minimum distance or nearest points will throw an OutOfRangeexception. If the curves are not parallel, information about extremal points can be obtained as shown below:

// Construt a line
AMCAX::Point3 start{ 0.,4.,0. };
AMCAX::Point3 end{ 1.,4.,0. };
auto line = AMCAX::MakeGeom3Line(start, end).Value();
// Construct an ellipse
AMCAX::Point3 point{ 0.,0.,0. };
AMCAX::Direction3 dir_z{ 0.,0.,1. };
AMCAX::Direction3 dir_x{ 1.,0.,0. };
AMCAX::Frame3 frame(point, dir_z, dir_x);
double majorRadius = 4.;
double minorRadius = 3.;
auto ellipse = AMCAX::MakeGeom3Ellipse::MakeGeom3Ellipse(frame, majorRadius, minorRadius).Value();
// Compute extremal points for two 3D curves
double u1min = -5.;// The first parameter of the first curve
double u1max = 5.;// The last parameter of the first curve
double u2min = ellipse->FirstParameter();// The first parameter of the second curve
double u2max = ellipse->LastParameter();// The last parameter of the second curve
AMCAX::GeomAPIExtremaCurveCurve3 excc(line, ellipse, u1min, u1max, u2min, u2max);
if (excc.IsParallel()) // parallel case, no extremal points, only extremal distance
{
double dist = excc.LowerDistance(); // minimum distance
}
else
{
if (excc.NExtrema() > 0)
{
// Get the nearest points
AMCAX::Point3 p1;// The nearest point on the first curve
AMCAX::Point3 p2;// The nearest point on the second curve
excc.NearestPoints(p1, p2);
std::cout << "p1:" << p1 << std::endl;// p1:2.44929e-16 4 0
std::cout << "p2:" << p2 << std::endl;// p2:2.44929e-16 3 0
// Get the parameters of the nearest points
double param1, param2;
excc.LowerDistanceParameters(param1, param2);
std::cout << "param1:" << param1 << std::endl;// param1: 2.44929e-16
std::cout << "param2:" << param2 << std::endl;// param2: 1.5708
// Get the distance of the nearest points
double nearestdist = excc.LowerDistance();
std::cout << "nearestdist:" << nearestdist << std::endl;// nearestdist:1
}
for (int i = 0; i < excc.NExtrema(); i++)
{
std::cout << "the" << " " << i << " " << "extremal point:" << std::endl;
// Get the extremal points at a given index
AMCAX::Point3 p1;// The extremal point on the first curve
AMCAX::Point3 p2;// The extremal point on the second curve
excc.Points(i, p1, p2);
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
// Get the parameters of the extrema at a given index
double param1;// The parameter of the extremal point on the first curve
double param2;// The parameter of the extremal point on the second curve
excc.Parameters(i, param1, param2);
std::cout << "param1: " << param1 << std::endl;
std::cout << "param2: " << param2 << std::endl;
// Get the extremal distance at a given index
double dist = excc.Distance(i);
std::cout << "dist: " << dist << std::endl;
std::cout << std::endl;
}
}
Class of computing extremal points for two 3D curves.
Definition GeomAPIExtremaCurveCurve3.hpp:21
AMCAX_API MakeGeom3Ellipse(const Ellipse3 &e)
Construct from an ellipse.
AMCAX_API const std::shared_ptr< Geom3Line > & Value() const
Get the constructed line.

Extremal Values Between Curves and Surfaces

The AMCAX::GeomAPIExtremaCurveSurfaceclass is used to compute minimum distance points between a curve and a surface. For input curves and surfaces, first use AMCAX::GeomAPIExtremaCurveSurface::IsParallelto determine if they are parallel. If they are parallel, extremal points do not exist, NExtrema()returns 1, and attempting to get the minimum distance or nearest points will throw an OutOfRangeexception. If they are not parallel, information about extremal points can be obtained as shown below:

// Construct an ellipse
AMCAX::Point3 point{ 0.,0.,0. };
AMCAX::Direction3 dir_z{ 0.,0.,1. };
AMCAX::Direction3 dir_x{ 1.,0.,0. };
AMCAX::Frame3 frame(point, dir_z, dir_x);
double majorRadius = 4.;
double minorRadius = 3.;
auto ellipse = AMCAX::MakeGeom3Ellipse::MakeGeom3Ellipse(frame, majorRadius, minorRadius).Value();
// Construct a trimmed plane
AMCAX::Point3 p(2.0, 0.0, 0.0);
AMCAX::Direction3 dir2(1., 1., 1.);
AMCAX::MakeGeom3Plane mgp(p, dir2);
std::shared_ptr< AMCAX::Geom3Plane > plane = mgp.Value();
double u1 = 0., u2 = 5., v1 = 0., v2 = 5.;
auto trimplane = std::make_shared<AMCAX::Geom3TrimmedSurface>(plane, u1, u2, v1, v2);
// Compute extremal points for a curve and a surface
double tmin = ellipse->FirstParameter();// The first parameter of the curve
double tmax = ellipse->LastParameter();// The last parameter of the curve
double umin = trimplane->FirstUParameter();// The u first parameter of the surface
double umax = trimplane->LastUParameter();// The u last parameter of the surface
double vmin = trimplane->FirstVParameter();// The v first parameter of the surface
double vmax = trimplane->LastVParameter();// The v last parameter of the surface
AMCAX::GeomAPIExtremaCurveSurface excs(ellipse, trimplane, tmin, tmax, umin, umax, vmin, vmax);
if (excs.IsParallel()) // parallel case, no extremal points, only extremal distance
{
double dist = excs.LowerDistance(); // minimum distance
}
else
{
if (excs.NExtrema() > 0)
{
// Get the nearest points
AMCAX::Point3 p1;// The extremal point on the curve
AMCAX::Point3 p2;// The extremal point on the surface
excs.NearestPoints(p1, p2);
std::cout << "p1:" << p1 << std::endl;// p1:3.2 1.8 0
std::cout << "p2:" << p2 << std::endl;// p2:2.2 0.8 -1
// Get the parameters of the nearest points
double t;// The parameter of the nearest point on the curve
double u;// The u parameter of the nearest point on the surface
double v;// The v parameter of the nearest point on the surface
excs.LowerDistanceParameters(t, u, v);
std::cout << "t: " << t << std::endl;// t: 0.643501
std::cout << "u: " << u << std::endl;// u: 0.848528
std::cout << "v: " << v << std::endl;// v: 0.979796
// Get the distance of the nearest points
double nearestdist = excs.LowerDistance();
std::cout << "nearestdist:" << nearestdist << std::endl;// nearestdist:1.73205
}
for (int i = 0; i < excs.NExtrema(); i++)
{
std::cout << "the" << " " << i << " " << "extremal point:" << std::endl;
// Get the extremal points at a given index
AMCAX::Point3 p1;// The extremal point on the curve
AMCAX::Point3 p2;// The extremal point on the surface
excs.Points(i, p1, p2);
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
// Get the parameters of the extrema at a given index
double t;// The parameter of the extremal point on the curve
double u;// The u parameter of the extremal point on the surface
double v;// The v parameter of the extremal point on the surface
excs.Parameters(i, t, u, v);
std::cout << "t: " << t << std::endl;
std::cout << "u: " << u << std::endl;
std::cout << "v: " << v << std::endl;
// Get the extremal distance at a given index
double dist = excs.Distance(i);
std::cout << "dist: " << dist << std::endl;
std::cout << std::endl;
}
}
Class of computing extremal points for a curve and a surface.
Definition GeomAPIExtremaCurveSurface.hpp:20

Thin-Plate Spline Curve Interpolation

During interpolation, it is clear that the curves passing through the points are not unique.

Generally, the blue curve better aligns with CAD design intent than the green curve. To ensure curves are not excessively long or overly bent, we use thin-plate energy as a measure of curve quality:

​​E1​​ controls curve length, ​​E2​​ controls the rate of curvature change. Higher ​​alpha​​ results in shorter curves.
The AMCAX::NURBSAPIInterpolateclass provides thin-plate spline curve interpolation functionality.

// Date Points
std::vector<AMCAX::Point3> points;
points.push_back(AMCAX::Point3(0.0, 0.0, 0.0));
points.push_back(AMCAX::Point3(-0.1, 1.0, -0.2));
points.push_back(AMCAX::Point3(0.1, 2.0, -0.1));
points.push_back(AMCAX::Point3(0.2, 3.0, 0.1));
points.push_back(AMCAX::Point3(0.1, 4.0, 0.0));
points.push_back(AMCAX::Point3(0.0, 5.0, -0.1));
// Configure Parameterization
bool isClosed = false;
double alpha = 1e-2;// The weight of D1 Thin Plate Energy
double beta = 1e-2;// The weight of D2 Thin Plate Energy
std::vector< double > parameterization = { 0.0,0.1,0.2,0.3,0.4,0.5 };// The parameterization of the points
// Interpolate points to make a curve
auto thinplate1 = AMCAX::NURBSAPIInterpolate::InterpolatePointsThinPlate(points, isClosed, ptype, alpha, beta);
auto thinplate2 = AMCAX::NURBSAPIInterpolate::InterpolatePointsThinPlate(points, parameterization, isClosed, alpha, beta);
// Data nodes
std::vector<AMCAX::InterpolationNode> nodes;
AMCAX::Point3 p1(0., 0., 0.);
AMCAX::Point3 p2(1., 1., 1.);
AMCAX::Vector3 v1(2., 0., 0.);
AMCAX::Vector3 v2(0., 0., 0.);
nodes.push_back({ p1,true,v1,false,v2 });
nodes.push_back({ p2,true,v1,false,v2 });
std::vector<double> parameterization1{ 0.0,0.5 };// The parameterization of the points
// Interpolate points to make a curve
auto thinplate3 = AMCAX::NURBSAPIInterpolate::InterpolateNodesThinPlate(nodes, isClosed, ptype, alpha, beta);
auto thinplate4 = AMCAX::NURBSAPIInterpolate::InterpolateNodesThinPlate(nodes, parameterization1, isClosed, alpha, beta);
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > InterpolateNodesThinPlate(const std::vector< InterpolationNode > &nodes, bool isClosed=false, ApproxParameterizationType ptype=ApproxParameterizationType::ChordLength, double alpha=1e-3, double beta=1e-3)
The curve which interpolate the points with gradients is constructed with Thin Plate Energy.
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > InterpolatePointsThinPlate(const std::vector< Point3 > &points, bool isClosed, ApproxParameterizationType ptype, double alpha, double beta)
Interpolate points to make a BSpline curve with Thin Plate Energy.
ApproxParameterizationType
Type of the parameterization used in curve approximation.
Definition ApproxParameterizationType.hpp:12
@ ChordLength
Parameters of points are proportional to distances between them.
Definition ApproxParameterizationType.hpp:14

Converting Law Curves to 3D Geometric Curves

The AMCAX::LawFunction::ToCurve()method converts a law curve into a 3D geometric curve.
For example, with a constant function: r​​ corresponds to the y-value, ​​pf​​ and ​​pl​​ are the start and end parameters in the x-direction.

double r = 5.0;
double pr = 1.0;
double pl = 10.0;
// Set the parameters
law.Set(r, pr, pl);
// Get the result curve
auto curve = law.ToCurve();
Class of constant law function.
Definition LawConstant.hpp:12
AMCAX_API void Set(double r, double pf, double pl)
Set the parameters.
AMCAX_API std::shared_ptr< Geom3Curve > ToCurve() const override
Turn the law function to a curve.