Construction of Curves and Surfaces
Abstract Curves and Surfaces
Curves
Lines
The AMCAX::MakeLine2 class is used to create a two-dimensional line.
double p1 = 0.;
double p2 = 1.;
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.
double p1 = 0.;
double p2 = 1.;
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.;
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.;
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.
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.
double radius = center.Distance(A);
double theta = 270.;
Class of edge.
Definition TopoEdge.hpp:12
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.;
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.;
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.;
double p1 = -1.;
double p2 = 1.;
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.;
double p1 = -1.;
double p2 = 1.;
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.;
double p1 = -1.;
double p2 = 1.;
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.;
double p1 = -1.;
double p2 = 1.;
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.
double uMin = 0.;
double uMax = 2.;
double vMin = 0.;
double vMax = 2.;
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.
double r1 = 2.;
double r2 = 1.;
double uMin = 0.;
double uMax = 2.;
double vMin = 0.;
double vMax = 2.;
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.;
double uMin = 0.;
double uMax = 2.;
double vMin = 0.;
double vMax = 2.;
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.
std::shared_ptr<AMCAX::Geom2Line> geomline2d = mgl.Value();
double p1 = 0.;
double p2 = 1.;
Class of making 2D geometric lines.
Definition MakeGeom2Line.hpp:13
The AMCAX::MakeGeom3Line class is used to create a three-dimensional geometric line.
std::shared_ptr<AMCAX::Geom3Line> geomline3d = mgl.Value();
double p1 = 0.;
double p2 = 1.;
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.;
std::shared_ptr<AMCAX::Geom2Circle> geomcircle2d = mgc.Value();
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.;
std::shared_ptr<AMCAX::Geom3Circle> geomcircle3d = mgc.Value();
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.;
std::shared_ptr<AMCAX::Geom2Ellipse> geomellipse2d = mge.Value();
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.;
std::shared_ptr<AMCAX::Geom3Ellipse> geomellipse3d = mge.Value();
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.;
std::shared_ptr<AMCAX::Geom2Hyperbola> geomhyperbola2d = mgh.Value();
double p1 = -1.;
double p2 = 1.;
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.;
std::shared_ptr<AMCAX::Geom3Hyperbola> geomhyperbola3d = mgh.Value();
double p1 = -1.;
double p2 = 1.;
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.;
std::shared_ptr<AMCAX::Geom2Parabola> geomparabola2d = mgp.Value();
double p1 = -3.;
double p2 = 3.;
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.;
std::shared_ptr<AMCAX::Geom3Parabola> geomparabola3d = mgp.Value();
double p1 = -3.;
double p2 = 3.;
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.
std::shared_ptr<AMCAX::Geom3Plane> geomplane = mgp.Value();
double uMin = -1.;
double uMax = 1.;
double vMin = -1.;
double vMax = 1.;
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.;
std::shared_ptr<AMCAX::Geom3ConicalSurface> geomconicalsurface = mgc.Value();
double uMin = 0.;
double vMin = 0.;
double vMax = 100.;
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.;
std::shared_ptr<AMCAX::Geom3CylindricalSurface> geomcylindricalsurface = mgcy.Value();
double uMin = 0.;
double vMin = 0.;
double vMax = 3.;
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.
std::shared_ptr<AMCAX::Geom2TrimmedCurve> s2d = ms2d.Value();
Class of making 2D line segments.
Definition MakeSegment2d.hpp:17
The AMCAX::MakeSegment class is used to create a three-dimensional line segment.
std::shared_ptr<AMCAX::Geom3TrimmedCurve> s3d = ms3d.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofcircle = marc.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofcircle = marc.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofellipse = marce.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofellipse = marce.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofhyperbola = march.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofhyperbola = march.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom2TrimmedCurve> arcofparabola = marcp.Value();
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.;
double alpha1 = 0.;
double alpha2 = 2.;
std::shared_ptr<AMCAX::Geom3TrimmedCurve> arcofparabola = marcp.Value();
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.
double r1 = 2.;
double r2 = 1.;
std::shared_ptr<AMCAX::Geom3TrimmedSurface> tc = mtc.Value();
Class of making trimmed cones.
Definition MakeTrimmedCone.hpp:17
Trimmed Cylindrical Surfaces
The AMCAX::MakeTrimmedCylinder class is used to create a trimmed cylindrical surface.
std::shared_ptr<AMCAX::Geom3TrimmedSurface> tc = mtc.Value();
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:
std::shared_ptr<AMCAX::Geom3TrimmedSurface> tc = mtc.Value();
double u = 2., v = 0.9;
std::cout << tc->Value(u, v) << std::endl;
tc->D0(u, v, p);
std::cout << p << std::endl;
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.
std::vector<AMCAX::Point2> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
}
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:
std::vector<AMCAX::Point2> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
std::vector<AMCAX::Vector2> tangents = {
};
std::vector<bool> tangentFlags = { true, true, true, true, true };
interpolate.Load(tangents, tangentFlags, true);
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
}
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:
std::vector<AMCAX::Point2> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
interpolate.Load(initialTangent, finalTangent, true);
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
}
else
std::cout << "error:interpolate failed" << std::endl;
Three-dimensional Interpolation Curves
The AMCAX::GeomAPIInterpolate3 class is used to compute three-dimensional interpolation curves.
std::vector<AMCAX::Point3> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate.Curve();
}
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:
std::vector<AMCAX::Point3> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
std::vector<AMCAX::Vector3> tangents = {
};
std::vector<bool> tangentFlags = { true, true, true, true, true };
interpolate.Load(tangents, tangentFlags, true);
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate.Curve();
}
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:
std::vector<AMCAX::Point3> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
interpolate.Load(initialTangent, finalTangent, true);
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate.Curve();
}
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.
std::vector<AMCAX::Point2> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin = 3;
int degMax = 8;
double tol = 1e-3;
if (ptb.IsDone())
{
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve = ptb.Curve();
}
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.
std::vector<AMCAX::Point2> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin = 3;
int degMax = 8;
double tol = 1e-6;
std::vector<double> yValues = { 0.0, 1.0, 0.5, 2.0, 1.5 };
double x0 = 0.;
double dx = 1.;
if (ptb.IsDone())
{
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve = ptb.Curve();
}
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.
std::vector<AMCAX::Point3> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin = 3;
int degMax = 8;
double tol = 1e-3;
if (ptb.IsDone()) {
std::shared_ptr<AMCAX::Geom3BSplineCurve> BSplineCurve = ptb.Curve();
}
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.
int degMin = 3;
int degMax = 8;
double tol = 1e-3;
if (ptbs.IsDone())
{
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsurface = ptbs.Surface();
}
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.
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;
double dx = 1.0;
double y0 = 0.0;
double dy = 1.0;
int degMin = 3;
int degMax = 8;
double tol = 1e-3;
if (ptbs.IsDone())
{
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsurface = ptbs.Surface();
}
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:
std::vector<AMCAX::Point2> pts = {
};
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);
double radius = 1.;
auto circle = std::make_shared<AMCAX::Geom2Circle>(frame, radius);
std::cout << cc.NPoints() << std::endl;
std::cout << cc.Point(0) << std::endl;
std::cout << cc.Point(1) << std::endl;
std::cout << cc.ParamOnCurve1(0) << std::endl;
std::cout << cc.ParamOnCurve1(1) << std::endl;
std::cout << cc.ParamOnCurve2(0) << std::endl;
std::cout << cc.ParamOnCurve2(1) << std::endl;
Class of computing intersection points for two 2D curves.
Definition GeomAPIIntCurveCurve2.hpp:19
Example with intersection segments as results:
auto line = std::make_shared<AMCAX::Geom2Line>(point, dir);
double u1 = 0., u3 = 2.;
double u2 = 3., u4 = 4.;
auto trimline1 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line, u1, u2);
auto trimline2 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line, u3, u4);
std::cout << cc.NSegments() << std::endl;
std::pair<double, double> paramOnCurve1;
std::pair<double, double> paramOnCurve2;
cc.Segment(0, paramOnCurve1, paramOnCurve2);
std::cout << paramOnCurve1.first << std::endl;
std::cout << paramOnCurve1.second << std::endl;
std::cout << paramOnCurve2.first << std::endl;
std::cout << paramOnCurve2.second << std::endl;
Additionally, AMCAX::GeomAPIIntCurveCurve2 can be used to determine if a 2D curve self-intersects and compute the number of self-intersection points.
std::vector<AMCAX::Point2> pts = {
};
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);
std::cout << cc.NPoints() << std::endl;
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:
std::vector<AMCAX::Point3> pts = {
};
auto bezier = std::make_shared<AMCAX::Geom3BezierCurve>(pts);
double radius = 3.;
std::shared_ptr<AMCAX::Geom3CylindricalSurface> CylindricalSurface = std::make_shared<AMCAX::Geom3CylindricalSurface>(frame, radius);
double param1 = 0.;
double param2 = 5.;
bool uTrim = false;
std::shared_ptr<AMCAX::Geom3TrimmedSurface> TrimmedSurface = std::make_shared<AMCAX::Geom3TrimmedSurface>(CylindricalSurface, param1, param2, uTrim);
cs.Perform(bezier, TrimmedSurface);
if (cs.IsDone())
{
std::cout << cs.NPoints() << std::endl;
double u = 0., v = 0., w = 0.;
cs.Parameters(0, u, v, w);
std::cout << u << std::endl;
std::cout << v << std::endl;
std::cout << w << std::endl;
std::cout << cs.Point(0) << std::endl;
}
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.
double radius = 3.;
std::shared_ptr<AMCAX::Geom3CylindricalSurface> CylindricalSurface = std::make_shared<AMCAX::Geom3CylindricalSurface>(frame, radius);
double param1 = 0.;
double param2 = 5.;
bool uTrim = false;
std::shared_ptr<AMCAX::Geom3TrimmedSurface> trimcylinder = std::make_shared<AMCAX::Geom3TrimmedSurface>(CylindricalSurface, param1, param2, uTrim);
auto plane = std::make_shared<AMCAX::Geom3Plane>(frame);
double u1 = 0.;
double u2 = 5.;
double v1 = 0.;
double v2 = 5.;
std::shared_ptr<AMCAX::Geom3TrimmedSurface> trimplane = std::make_shared<AMCAX::Geom3TrimmedSurface>(plane, u1, u2, v1, v2);
if (ss.IsDone())
{
std::cout << ss.NLines() << std::endl;
std::shared_ptr<AMCAX::Geom3Curve> line = ss.Line(0);
}
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:
std::vector<AMCAX::Point2> pts1 = {
};
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);
std::vector<AMCAX::Point2> pts2;
for (const auto& pt : pts1) {
}
auto bspline2 = std::make_shared<AMCAX::Geom2BSplineCurve>(pts2, knots1, mults1, degree);
double u1min = bspline1->FirstParameter();
double u1max = bspline1->LastParameter();
double u2min = bspline2->FirstParameter();
double u2max = bspline2->LastParameter();
if (excc.IsParallel())
{
double dist = excc.LowerDistance();
}
else
{
if (excc.NExtrema() > 0)
{
excc.NearestPoints(p1, p2);
std::cout << "p1:" << p1 << std::endl;
std::cout << "p2:" << p2 << std::endl;
double param1, param2;
excc.LowerDistanceParameters(param1, param2);
std::cout << "param1:" << param1 << std::endl;
std::cout << "param2:" << param2 << std::endl;
double nearestdist = excc.LowerDistance();
std::cout << "nearestdist:" << nearestdist << std::endl;
}
for (int i = 0; i < excc.NExtrema(); i++)
{
std::cout << "the" << " " << i << " " << "extremal point:" << std::endl;
excc.Points(i, p1, p2);
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
double param1;
double param2;
excc.Parameters(i, param1, param2);
std::cout << "param1: " << param1 << std::endl;
std::cout << "param2: " << param2 << std::endl;
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:
double majorRadius = 4.;
double minorRadius = 3.;
double u1min = -5.;
double u1max = 5.;
double u2min = ellipse->FirstParameter();
double u2max = ellipse->LastParameter();
if (excc.IsParallel())
{
double dist = excc.LowerDistance();
}
else
{
if (excc.NExtrema() > 0)
{
excc.NearestPoints(p1, p2);
std::cout << "p1:" << p1 << std::endl;
std::cout << "p2:" << p2 << std::endl;
double param1, param2;
excc.LowerDistanceParameters(param1, param2);
std::cout << "param1:" << param1 << std::endl;
std::cout << "param2:" << param2 << std::endl;
double nearestdist = excc.LowerDistance();
std::cout << "nearestdist:" << nearestdist << std::endl;
}
for (int i = 0; i < excc.NExtrema(); i++)
{
std::cout << "the" << " " << i << " " << "extremal point:" << std::endl;
excc.Points(i, p1, p2);
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
double param1;
double param2;
excc.Parameters(i, param1, param2);
std::cout << "param1: " << param1 << std::endl;
std::cout << "param2: " << param2 << std::endl;
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:
double majorRadius = 4.;
double minorRadius = 3.;
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);
double tmin = ellipse->FirstParameter();
double tmax = ellipse->LastParameter();
double umin = trimplane->FirstUParameter();
double umax = trimplane->LastUParameter();
double vmin = trimplane->FirstVParameter();
double vmax = trimplane->LastVParameter();
if (excs.IsParallel())
{
double dist = excs.LowerDistance();
}
else
{
if (excs.NExtrema() > 0)
{
excs.NearestPoints(p1, p2);
std::cout << "p1:" << p1 << std::endl;
std::cout << "p2:" << p2 << std::endl;
double t;
double u;
double v;
excs.LowerDistanceParameters(t, u, v);
std::cout << "t: " << t << std::endl;
std::cout << "u: " << u << std::endl;
std::cout << "v: " << v << std::endl;
double nearestdist = excs.LowerDistance();
std::cout << "nearestdist:" << nearestdist << std::endl;
}
for (int i = 0; i < excs.NExtrema(); i++)
{
std::cout << "the" << " " << i << " " << "extremal point:" << std::endl;
excs.Points(i, p1, p2);
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
double t;
double u;
double v;
excs.Parameters(i, t, u, v);
std::cout << "t: " << t << std::endl;
std::cout << "u: " << u << std::endl;
std::cout << "v: " << v << std::endl;
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.
std::vector<AMCAX::Point3> points;
bool isClosed = false;
double alpha = 1e-2;
double beta = 1e-2;
std::vector< double > parameterization = { 0.0,0.1,0.2,0.3,0.4,0.5 };
std::vector<AMCAX::InterpolationNode> nodes;
nodes.push_back({ p1,true,v1,false,v2 });
nodes.push_back({ p2,true,v1,false,v2 });
std::vector<double> parameterization1{ 0.0,0.5 };
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;
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.