Package geomss.geom.nurbs
Class CurveFactory
- java.lang.Object
-
- geomss.geom.nurbs.CurveFactory
-
public final class CurveFactory extends java.lang.Object
A collection of methods for creating NURBS curves.Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Samuel Gerber, Date: May 14, 2009, Version 1.0.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BasicNurbsCurve
approxPoints(int degree, int nCP, PointString<? extends GeomPoint> points)
Create aNurbsCurve
of the specified degree that approximates, in a least squared error sense, the specified list of geometry points in the input order.static KnotVector
buildInterpKnotVector(double[] uk, int numPoints, int p)
Create a vector of knots to go with the list of parameter values for a curve that passes through a list of points.static BasicNurbsCurve
createBlend(GeomPoint p1, GeomVector t1, GeomPoint p2, GeomVector t2, boolean unitFlag, double tanlen)
Create a potentially non-planar cubic BezierNurbsCurve
that joins or blends two end points with the specified tangent vectors at each end point.static BasicNurbsCurve
createCircle(GeomPoint p1, GeomPoint p2, GeomPoint p3)
Create a full-circleNurbsCurve
that passes through the input (not co-linear) points.static BasicNurbsCurve
createCircle(GeomPoint o, Parameter<javax.measure.quantity.Length> r, GeomVector<javax.measure.quantity.Dimensionless> n)
Create a full-circleNurbsCurve
around the given origin/center with radiusr
.static BasicNurbsCurve
createCircleO(GeomPoint o, GeomPoint p1, GeomPoint p2)
Create a full-circleNurbsCurve
that is approximately centered on the specified origin point and passes through the two input points.static BasicNurbsCurve
createCircularArc(GeomPoint p1, GeomPoint p2, GeomPoint p3)
Create a circular arcNurbsCurve
that passes through the input (not co-linear) points.static BasicNurbsCurve
createCircularArc(GeomPoint p1, GeomVector t1, GeomPoint p2)
Create a circular arcNurbsCurve
that passes through the input points and that has the input tangents at the 1st point.static BasicNurbsCurve
createCircularArc(GeomPoint o, Parameter<javax.measure.quantity.Length> r, GeomVector<javax.measure.quantity.Dimensionless> n, Parameter<javax.measure.quantity.Angle> thetaS, Parameter<javax.measure.quantity.Angle> thetaE)
Create a circular arcNurbsCurve
about the specified origin, with the specified radius and angular start and stop values.static BasicNurbsCurve
createCircularArcO(GeomPoint o, GeomPoint p1, GeomPoint p2)
Create a circular arcNurbsCurve
that is approximately centered on the specified origin point and passes through the two input points.static BasicNurbsCurve
createEllipse(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, GeomVector<javax.measure.quantity.Dimensionless> n)
Create a full-ellipseNurbsCurve
around the given origin/center with semi-major axis lengtha
and semi-minor axis lengthb
.static BasicNurbsCurve
createEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, GeomVector<javax.measure.quantity.Dimensionless> xhat, GeomVector<javax.measure.quantity.Dimensionless> yhat, Parameter<javax.measure.quantity.Angle> thetaS, Parameter<javax.measure.quantity.Angle> thetaE)
Create an elliptical arcNurbsCurve
about the specified origin, with the specified semi-major axis length, semi-minor axis length and angular start and stop values.static BasicNurbsCurve
createLine(int degree, GeomPoint p0, GeomPoint p1)
Create a straight lineNurbsCurve
that represents the shortest distance, in Euclidean space between the two input points with the specified degree.static BasicNurbsCurve
createLine(GeomPoint p0, GeomPoint p1)
Create a 1-degree straight lineNurbsCurve
that represents the shortest distance, in Euclidean space between the two input points.static BasicNurbsCurve
createParabolicArc(GeomPoint p0, GeomVector<javax.measure.quantity.Dimensionless> t0, GeomPoint p2, GeomVector<javax.measure.quantity.Dimensionless> t2)
Create a planar parabolic arcNurbsCurve
that joins two end points with the specified tangent vectors at each end point.static BasicNurbsCurve
createPoint(int degree, int numCP, GeomPoint p0)
Create a degenerateNurbsCurve
of the specified degree that represents a point in space with the indicated number of co-located control points.static BasicNurbsCurve
createPoint(int degree, GeomPoint p0)
Create a degenerateNurbsCurve
of the specified degree that represents a point in space.static BasicNurbsCurve
createSemiCircle(GeomPoint o, Parameter<javax.measure.quantity.Length> r, GeomVector<javax.measure.quantity.Dimensionless> n)
Create a semi-circleNurbsCurve
with the specified normal vector around the given origin with radiusr
.static BasicNurbsCurve
createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double m, double n, GeomVector<javax.measure.quantity.Dimensionless> xhat, GeomVector<javax.measure.quantity.Dimensionless> yhat, Parameter<javax.measure.quantity.Length> tol)
Create the first quadrant of a general super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponents.static BasicNurbsCurve
createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double m, double n, GeomVector<javax.measure.quantity.Dimensionless> nhat, Parameter<javax.measure.quantity.Length> tol)
Create the first quadrant of a general super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponents.static BasicNurbsCurve
createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double n, GeomVector<javax.measure.quantity.Dimensionless> nhat)
Create the first quadrant of a common exponent super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponent.static BasicNurbsCurve
createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double n, GeomVector<javax.measure.quantity.Dimensionless> xhat, GeomVector<javax.measure.quantity.Dimensionless> yhat)
Create the first quadrant of a common exponent super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponent.static BasicNurbsCurve
fitPoints(int degree, PointString<? extends GeomPoint> points)
Create aNurbsCurve
of the specified degree that is fit to, interpolates, or passes through the specified list of geometry points in the input order.static BasicNurbsCurve
fitPoints(int degree, PointString<? extends GeomPoint> points, double[] uk, KnotVector uKnots)
Create aNurbsCurve
of the specified degree that is fit to, interpolates, or passes through the specified list of geometry points in the input order.static BasicNurbsCurve
fitPoints(int degree, PointString<? extends GeomPoint> points, java.util.List<GeomVector> tangents, boolean unitFlag, double tanlen)
Create aNurbsCurve
of the specified degree that is fit to, interpolates, or passes through the specified list of geometry points constrained to the input list of tangent vectors at each point in the input order.static void
parameterizationCheck(int size, double[] uk)
Check the array of parameterization values and reports any problems by throwing a ParameterException.static double[]
parameterizeString(PointString<? extends GeomPoint> points)
Turn a string of points into a list of parameter values along a curve through those points.
-
-
-
Method Detail
-
createPoint
public static BasicNurbsCurve createPoint(int degree, GeomPoint p0)
Create a degenerateNurbsCurve
of the specified degree that represents a point in space.- Parameters:
degree
- The degree of the curve to create.p0
- The location for the degenerate curve. May not be null.- Returns:
- A BasicNurbsCurve that represents a point.
-
createPoint
public static BasicNurbsCurve createPoint(int degree, int numCP, GeomPoint p0)
Create a degenerateNurbsCurve
of the specified degree that represents a point in space with the indicated number of co-located control points.- Parameters:
degree
- The degree of the curve to create.numCP
- The number of control points to use in the degenerate curve.p0
- The location for the degenerate curve. May not be null.- Returns:
- A BasicNurbsCurve that represents a point.
-
createLine
public static BasicNurbsCurve createLine(GeomPoint p0, GeomPoint p1)
Create a 1-degree straight lineNurbsCurve
that represents the shortest distance, in Euclidean space between the two input points.- Parameters:
p0
- The start of the line. May not be null.p1
- The end of the line. May not be null.- Returns:
- A BasicNurbsCurve that represents a line between the input points.
-
createLine
public static BasicNurbsCurve createLine(int degree, GeomPoint p0, GeomPoint p1)
Create a straight lineNurbsCurve
that represents the shortest distance, in Euclidean space between the two input points with the specified degree.- Parameters:
degree
- The degree of the NurbsCurve to return.p0
- The start of the line. May not be null.p1
- The end of the line. May not be null.- Returns:
- A BasicNurbsCurve of the specified degree that represents a line between the input points.
-
createSemiCircle
public static BasicNurbsCurve createSemiCircle(GeomPoint o, Parameter<javax.measure.quantity.Length> r, GeomVector<javax.measure.quantity.Dimensionless> n) throws DimensionException
Create a semi-circleNurbsCurve
with the specified normal vector around the given origin with radiusr
. The curve returned has a control polygon which has 4 points and the shape of a rectangle.- Parameters:
o
- Origin to create a semi-circle around. May not be null.r
- Radius of the semi-circle May not be null.n
- A unit plane normal vector for the plane containing the circle. Ifnull
is passed, a default normal vector that points along the Z axis is used.- Returns:
- A BasicNurbsCurve that represents a semi-circle
- Throws:
DimensionException
- if the origin point or normal do not have at least 2 physical dimensions.
-
createCircle
public static BasicNurbsCurve createCircle(GeomPoint o, Parameter<javax.measure.quantity.Length> r, GeomVector<javax.measure.quantity.Dimensionless> n) throws DimensionException
Create a full-circleNurbsCurve
around the given origin/center with radiusr
. The NurbsCurve returned has a control polygon which has 9 control points and the shape of a square.- Parameters:
o
- Origin or center to create the full-circle around. May not be null.r
- Radius of the full-circle. May not be null.n
- A unit plane normal vector for the plane containing the circle. Ifnull
is passed, a default normal vector that points along the Z axis is used.- Returns:
- A BasicNurbsCurve for a full-circle
- Throws:
DimensionException
- if the origin point or normal do not have at least 2 physical dimensions.
-
createCircle
public static BasicNurbsCurve createCircle(GeomPoint p1, GeomPoint p2, GeomPoint p3) throws DimensionException
Create a full-circleNurbsCurve
that passes through the input (not co-linear) points. The curve will be parameterized with 0 at the starting point with the parameterization increasing toward the last point. The NurbsCurve returned has a control polygon which has 9 control points and the shape of square.- Parameters:
p1
- The 1st of the points that define the circle (must not be colinear with the other two). May not be null.p2
- The 2nd of the points that define the circle (must not be colinear with the other two). May not be null.p3
- The 3rd of the points that define the circle (must not be colinear with the other two). May not be null.- Returns:
- A BasicNurbsCurve for a full-circle
- Throws:
DimensionException
- if one of the 3 points does not have at least 2 physical dimensions.java.lang.IllegalArgumentException
- if the input points are co-linear.
-
createCircleO
public static BasicNurbsCurve createCircleO(GeomPoint o, GeomPoint p1, GeomPoint p2) throws DimensionException
Create a full-circleNurbsCurve
that is approximately centered on the specified origin point and passes through the two input points. The origin point is used to determine the plane that the circle lies in and is used to approximate the center of the circle. The true origin/center of the circle is calculated to ensure that the circle passes through the supplied edge points. The curve is parameterized such that 0 is at the first point and the parameterization increases toward the 2nd point. The NurbsCurve returned has a control polygon which has 9 control points and the shape of square.- Parameters:
o
- Approximate origin or center to create the full-circle around. May not be null.p1
- The 1st of the points that define the circle. May not be null.p2
- The 2nd of the points that define the circle. May not be null.- Returns:
- A BasicNurbsCurve for a full-circle
- Throws:
DimensionException
- if the origin or 2 points do not have at least 2 physical dimensions.
-
createEllipse
public static BasicNurbsCurve createEllipse(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, GeomVector<javax.measure.quantity.Dimensionless> n) throws DimensionException
Create a full-ellipseNurbsCurve
around the given origin/center with semi-major axis lengtha
and semi-minor axis lengthb
. The NurbsCurve returned has a control polygon which has 9 control points and the shape of a rectangle.- Parameters:
o
- Origin or center to create the full-ellipse around. May not be null.a
- Semi-major axis length. May not be null.b
- Semi-minor axis length. May not be null.n
- A unit plane normal vector for the plane containing the circle. Ifnull
is passed, a default normal vector that points along the Z axis is used.- Returns:
- A BasicNurbsCurve for a full-ellipse
- Throws:
DimensionException
- if the origin point or normal do not have at least 2 physical dimensions.
-
createCircularArc
public static BasicNurbsCurve createCircularArc(GeomPoint o, Parameter<javax.measure.quantity.Length> r, GeomVector<javax.measure.quantity.Dimensionless> n, Parameter<javax.measure.quantity.Angle> thetaS, Parameter<javax.measure.quantity.Angle> thetaE) throws DimensionException
Create a circular arcNurbsCurve
about the specified origin, with the specified radius and angular start and stop values.- Parameters:
o
- The origin to create the arc around. May not be null.r
- The radius of the circular arc. May not be null.n
- A unit plane normal vector for the plane containing the circle. Ifnull
is passed, a default normal vector that points along the Z axis is used.thetaS
- The start angle of the arc (relative to the X axis).thetaE
- The end angle of the arc (relative to the X axis). If the end angle is smaller than the start angle, it is increased by increments of 2*PI until it is larger than the start angle.- Returns:
- A BasicNurbsCurve for a circular arc
- Throws:
DimensionException
- if the origin point or normal do not have at least 2 physical dimensions.
-
createCircularArc
public static BasicNurbsCurve createCircularArc(GeomPoint p1, GeomPoint p2, GeomPoint p3) throws DimensionException
Create a circular arcNurbsCurve
that passes through the input (not co-linear) points. The curve will be parameterized with 0 at the starting point and 1 at the last point.- Parameters:
p1
- The 1st of the points that define the arc (must not be colinear with the other two). May not be null.p2
- The 2nd of the points that define the arc (must not be colinear with the other two). May not be null.p3
- The 3rd of the points that define the arc (must not be colinear with the other two). May not be null.- Returns:
- A BasicNurbsCurve for a circular arc through the input points
- Throws:
DimensionException
- if one of the 3 points does not have at least 2 physical dimensions.java.lang.IllegalArgumentException
- if the input points are co-linear.
-
createCircularArc
public static BasicNurbsCurve createCircularArc(GeomPoint p1, GeomVector t1, GeomPoint p2) throws DimensionException
Create a circular arcNurbsCurve
that passes through the input points and that has the input tangents at the 1st point. The curve will be parameterized with 0 at the starting point and 1 at the last point.- Parameters:
p1
- The 1st of the points that define the arc. May not be null.t1
- The tangent vector at p1 (must not point at p2). May not be null.p2
- The 2nd of the points that define the arc. May not be null.- Returns:
- A BasicNurbsCurve for a circular arc through the input points with the input tangent vector at the start.
- Throws:
DimensionException
- if one of the 3 points does not have at least 2 physical dimensions.
-
createCircularArcO
public static BasicNurbsCurve createCircularArcO(GeomPoint o, GeomPoint p1, GeomPoint p2) throws DimensionException
Create a circular arcNurbsCurve
that is approximately centered on the specified origin point and passes through the two input points. The origin point is used to determine the plane that the circle lies in and is used to approximate the center of the circle. The true origin/center of the circle is calculated to ensure that the circle passes through the supplied edge points. The curve is parameterized such that 0 is at the first point and 1 is at the last point. The NurbsCurve returned has a control polygon which has 9 control points and the shape of square.- Parameters:
o
- Approximate origin or center to create the arc around. May not be null.p1
- The 1st of the points that define the arc. May not be null.p2
- The 2nd of the points that define the arc. May not be null.- Returns:
- A BasicNurbsCurve for a circular arc through the input points.
- Throws:
DimensionException
- if the origin or 2 points do not have at least 2 physical dimensions.
-
createEllipticalArc
public static BasicNurbsCurve createEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, GeomVector<javax.measure.quantity.Dimensionless> xhat, GeomVector<javax.measure.quantity.Dimensionless> yhat, Parameter<javax.measure.quantity.Angle> thetaS, Parameter<javax.measure.quantity.Angle> thetaE) throws DimensionException
Create an elliptical arcNurbsCurve
about the specified origin, with the specified semi-major axis length, semi-minor axis length and angular start and stop values.- Parameters:
o
- The origin to create the arc around. May not be null.a
- The ellipse semi-major axis length (half the ellipse diameter in the xhat direction). May not be null.b
- The ellipse semi-minor axis length (half the ellipse diameter in the yhat direction). May not be null.xhat
- A unit vector indicating the "X" or semi-major axis direction in the plane of the ellipse. This must be orthogonal to yhat. May not be null.yhat
- A unit vector indicating the "Y" or semi-minor direction in the plane of the ellipse. This must be orthogonal to xhat. May not be null.thetaS
- The start angle of the arc (relative to the xhat axis). May not be null.thetaE
- The end angle of the arc (relative to the xhat axis). If the end angle is smaller than the start angle, it is increased by increments of 2*PI until it is larger than the start angle. May not be null.- Returns:
- A BasicNurbsCurve for an elliptical arc
- Throws:
DimensionException
- if the origin point or axes do not have at least 2 physical dimensions.
-
createParabolicArc
public static BasicNurbsCurve createParabolicArc(GeomPoint p0, GeomVector<javax.measure.quantity.Dimensionless> t0, GeomPoint p2, GeomVector<javax.measure.quantity.Dimensionless> t2) throws DimensionException
Create a planar parabolic arcNurbsCurve
that joins two end points with the specified tangent vectors at each end point. If the input tangent vectors are either parallel or not coplanar, then a straight line between the two end points is returned. If the intersection of the two input tangent vectors does not fall between the two input end points, then a straight line between the two end points is returned.- Parameters:
p0
- The starting end of the arc. May not be null.t0
- The tangent vector at the starting end of the arc. May not be null.p2
- The stopping end of the arc. May not be null.t2
- The tangent vector at the stopping end of the arc. May not be null.- Returns:
- A BasicNurbsCurve for a parabolic arc between the input points.
- Throws:
DimensionException
- if the input points and tangents do not have at least 2 physical dimensions.- See Also:
createBlend(geomss.geom.GeomPoint, geomss.geom.GeomVector, geomss.geom.GeomPoint, geomss.geom.GeomVector, boolean, double)
-
createSuperEllipticalArc
public static BasicNurbsCurve createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double n, GeomVector<javax.measure.quantity.Dimensionless> nhat) throws DimensionException
Create the first quadrant of a common exponent super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponent. Other quadrants can be represented by reflection. A common exponent super-elliptic arc can be described using the following equation:
(x/a)^n + (y/b)^n = 1
where a is the semi-major and b is the semi-minor axis, and n is the exponent of the super-ellipse (n > 0). Special cases include a circle (with a = b, and n = 2), an ellipse (with a ≠ b, and n = 2) and a straight line (n = 1). If n is large, a box is approximated. This type of super-ellipse is represented exactly by a NURBS curve.- Parameters:
o
- The origin to create the arc around. May not be null.a
- The super-ellipse semi-major (or minor if b is major) axis. May not be null.b
- The super-ellipse semi-minor (or major if a is minor) axis. May not be null.n
- The exponent for the super-ellipse (must be > 0).nhat
- A unit plane normal vector for the plane containing the super-ellipse. Ifnull
is passed, a default normal vector that points along the Z axis is used.- Returns:
- A BasicNurbsCurve for the 1st quadrant of a super-ellipse.
- Throws:
DimensionException
-
createSuperEllipticalArc
public static BasicNurbsCurve createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double n, GeomVector<javax.measure.quantity.Dimensionless> xhat, GeomVector<javax.measure.quantity.Dimensionless> yhat) throws DimensionException
Create the first quadrant of a common exponent super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponent. Other quadrants can be represented by reflection. A super-elliptic arc can be described using the following equation:
(x/a)^n + (y/b)^n = 1
where a is the semi-major and b is the semi-minor axis, and n is the exponent of the super-ellipse (n > 0). Special cases include a circle (with a = b, and n = 2), an ellipse (with a ≠ b, and n = 2) and a straight line (n = 1). If n is large, a box is approximated. This type of super-ellipse is represented exactly by a NURBS curve.- Parameters:
o
- The origin to create the arc around. May not be null.a
- The super-ellipse semi-major (or minor if b is major) axis. May not be null.b
- The super-ellipse semi-minor (or major if a is minor) axis. May not be null.n
- The exponent for the super-ellipse (must be > 0).xhat
- A unit vector indicating the "X" or semi-major axis direction in the plane of the super-ellipse. This must be orthogonal to yhat. May not be null.yhat
- A unit vector indicating the "Y" or semi-minor axis direction in the plane of the super-ellipse. This must be orthogonal to xhat. May not be null.- Returns:
- A BasicNurbsCurve for the 1st quadrant of a super-ellipse.
- Throws:
DimensionException
-
createSuperEllipticalArc
public static BasicNurbsCurve createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double m, double n, GeomVector<javax.measure.quantity.Dimensionless> xhat, GeomVector<javax.measure.quantity.Dimensionless> yhat, Parameter<javax.measure.quantity.Length> tol) throws DimensionException, java.lang.IllegalArgumentException, org.apache.commons.math3.linear.SingularMatrixException, ParameterException
Create the first quadrant of a general super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponents. Other quadrants can be represented by reflection. A general super-elliptic arc can be described using the following equation:
(x/a)^m + (y/b)^n = 1
where a is the semi-major and b is the semi-minor axis, and m & n are the exponents of the super-ellipse (m & n > 0). Special cases include a circle (with a = b, and m = n = 2), an ellipse (with a ≠ b, and m = n = 2) and a straight line (m = n = 1). If m & n are large, a box is approximated. This type of super-ellipse is generally only approximated by a NURBS curve to the specified tolerance. If the input exponents are equal, then an exact representation is returned.- Parameters:
o
- The origin to create the arc around. May not be null.a
- The super-ellipse semi-major (or minor if b is major) axis. May not be null.b
- The super-ellipse semi-minor (or major if a is minor) axis. May not be null.m
- The exponent on the x/a term of the super-ellipse equation (must be > 0).n
- The exponent for the y/b term of the super-ellipse equation (must be > 0).xhat
- A unit vector indicating the "X" or semi-major axis direction in the plane of the super-ellipse. This must be orthogonal to yhat. May not be null.yhat
- A unit vector indicating the "Y" or semi-minor axis direction in the plane of the super-ellipse. This must be orthogonal to xhat. May not be null.tol
- A geometric tolerance on how accurately the NURBS curve must represent the true super-ellipse. If m == n, then an exact representation is returned and "tol" is ignored, otherwise tol may not be null.- Returns:
- A BasicNurbsCurve for the 1st quadrant of a super-ellipse.
- Throws:
DimensionException
java.lang.IllegalArgumentException
org.apache.commons.math3.linear.SingularMatrixException
ParameterException
-
createSuperEllipticalArc
public static BasicNurbsCurve createSuperEllipticalArc(GeomPoint o, Parameter<javax.measure.quantity.Length> a, Parameter<javax.measure.quantity.Length> b, double m, double n, GeomVector<javax.measure.quantity.Dimensionless> nhat, Parameter<javax.measure.quantity.Length> tol) throws DimensionException, java.lang.IllegalArgumentException, org.apache.commons.math3.linear.SingularMatrixException, ParameterException
Create the first quadrant of a general super-ellipseNurbsCurve
about the specified origin, with the specified semi-major and semi-minor axes and exponents. Other quadrants can be represented by reflection. A general super-elliptic arc can be described using the following equation:
(x/a)^m + (y/b)^n = 1
where a is the semi-major and b is the semi-minor axis, and m & n are the exponents of the super-ellipse. Special cases include a circle (with a = b, and m = n = 2), an ellipse (with a ≠ b, and m = n = 2) and a straight line (m = n = 1). If m & n are large, a box is approximated. This type of super-ellipse is generally only approximated by a NURBS curve to the specified tolerance. If the input exponents are equal, then an exact representation is returned.- Parameters:
o
- The origin to create the arc around. May not be null.a
- The super-ellipse semi-major (or minor if b is major) axis. May not be null.b
- The super-ellipse semi-minor (or major if a is minor) axis. May not be null.m
- The exponent on the x/a term of the super-ellipse equation (must be > 0).n
- The exponent for the y/b term of the super-ellipse equation (must be > 0).nhat
- A unit plane normal vector for the plane containing the super-ellipse. Ifnull
is passed, a default normal vector that points along the Z axis is used.tol
- A geometric tolerance on how accurately the NURBS curve must represent the true super-ellipse. If m == n, then an exact representation is returned and "tol" is ignored, otherwise "tol" may not be null..- Returns:
- A BasicNurbsCurve for the 1st quadrant of a super-ellipse.
- Throws:
DimensionException
java.lang.IllegalArgumentException
org.apache.commons.math3.linear.SingularMatrixException
ParameterException
-
createBlend
public static BasicNurbsCurve createBlend(GeomPoint p1, GeomVector t1, GeomPoint p2, GeomVector t2, boolean unitFlag, double tanlen) throws DimensionException
Create a potentially non-planar cubic BezierNurbsCurve
that joins or blends two end points with the specified tangent vectors at each end point. If unit vectors are supplied, then they will be scaled by the distance between the end points and the multiplicative factor provided (tanlen).- Parameters:
p1
- The starting end of the arc. May not be null.t1
- The tangent vector at the starting end of the arc. May not be null.p2
- The stopping end of the arc. May not be null.t2
- The tangent vector at the stopping end of the arc. May not be null.unitFlag
- A flag indicating that the tangents are all unit vectors iftrue
.tanlen
- A multiplicative factor for the tangent (must be greater than 0 or the function aborts). Used only ifunitFlat == true
. Applied to the distance between end points to scale the tangent vectors.- Returns:
- A BasicNurbsCurve that represents a Bezier curve between the input points with the input tangent vectors.
- Throws:
DimensionException
- if the input points and tangents do not have at least 2 physical dimensions.- See Also:
createParabolicArc(geomss.geom.GeomPoint, geomss.geom.GeomVector<javax.measure.quantity.Dimensionless>, geomss.geom.GeomPoint, geomss.geom.GeomVector<javax.measure.quantity.Dimensionless>)
-
fitPoints
public static BasicNurbsCurve fitPoints(int degree, PointString<? extends GeomPoint> points) throws java.lang.IllegalArgumentException, org.apache.commons.math3.linear.SingularMatrixException, ParameterException
Create aNurbsCurve
of the specified degree that is fit to, interpolates, or passes through the specified list of geometry points in the input order. This is a global interpolation of the points, meaning that if one of the input points is moved, it will affect the entire curve, not just the local portion near the point.- Parameters:
degree
- The degree of the NURBS curve to create (must be > 0 and ≤ the number of data points).points
- The string of GeomPoint objects to pass the curve through. May not be null.- Returns:
- A NurbsCurve fit to the input list of points.
- Throws:
java.lang.IllegalArgumentException
- if the degree is ≤ 0 or ≥ the number of points input.org.apache.commons.math3.linear.SingularMatrixException
- if the decomposed matrix is singular.ParameterException
- See Also:
approxPoints(int, int, geomss.geom.PointString<? extends geomss.geom.GeomPoint>)
-
fitPoints
public static BasicNurbsCurve fitPoints(int degree, PointString<? extends GeomPoint> points, double[] uk, KnotVector uKnots) throws java.lang.IllegalArgumentException, org.apache.commons.math3.linear.SingularMatrixException
Create aNurbsCurve
of the specified degree that is fit to, interpolates, or passes through the specified list of geometry points in the input order. This is a global interpolation of the points, meaning that if one of the input points is moved, it will affect the entire curve, not just the local portion near the point.- Parameters:
degree
- The degree of the NURBS curve to create (must be > 0 and ≤ the number of data points).points
- The string of GeomPoint objects to pass the curve through. May not be null.uk
- The parameterization array to use for each of the input points. Must be monotonically increasing and must include 0 and 1. May not be null.uKnots
- The knot vector to use with the output curve. May not be null.- Returns:
- A NurbsCurve fit to the input list of points.
- Throws:
java.lang.IllegalArgumentException
- if the degree is ≤ 0 or ≥ the number of points input or the parameterization array is invalid.org.apache.commons.math3.linear.SingularMatrixException
- if the decomposed matrix is singular.- See Also:
approxPoints(int, int, geomss.geom.PointString, double[], geomss.geom.nurbs.KnotVector)
,parameterizeString(geomss.geom.PointString)
,buildInterpKnotVector(double[], int, int)
-
fitPoints
public static BasicNurbsCurve fitPoints(int degree, PointString<? extends GeomPoint> points, java.util.List<GeomVector> tangents, boolean unitFlag, double tanlen) throws java.lang.IllegalArgumentException, org.apache.commons.math3.linear.SingularMatrixException, ParameterException
Create aNurbsCurve
of the specified degree that is fit to, interpolates, or passes through the specified list of geometry points constrained to the input list of tangent vectors at each point in the input order. This is a global interpolation of the points, meaning that if one of the input points is moved, it will affect the entire curve, not just the local portion near the point.- Parameters:
degree
- The degree of the NURBS curve to create (must be > 0 and < the number of data points).points
- The string of Geom Point objects to pass the curve through. May not be null.tangents
- A list of tangent vectors, one for each point in "points". May not be null.unitFlag
- A flag indicating that the derivatives are all unit vectors iftrue
.tanlen
- A multiplicative factor for the tangent (must be greater than 0 or the function aborts and should be near 1.0). Used only ifunitFlag == true
.- Returns:
- A NurbsCurve fit to the input list of points and tangent vectors.
- Throws:
java.lang.IllegalArgumentException
- if the degree is ≤ 0 or ≥ the number of points input.org.apache.commons.math3.linear.SingularMatrixException
- if the decomposed matrix is singular.ParameterException
- See Also:
approxPoints(int, int, geomss.geom.PointString<? extends geomss.geom.GeomPoint>)
-
parameterizeString
public static double[] parameterizeString(PointString<? extends GeomPoint> points)
Turn a string of points into a list of parameter values along a curve through those points. Uses the chord length method. The returned array was created using ArrayFactor.DOUBLES_FACTORY and can be recycled.- Parameters:
points
- A string of points to be parameterized for use in a curve. May not be null.- Returns:
- An array of the parameterizations for each point in the points string. WARNING: the array will likely be longer than the length of the points string and the additional values will be garbage. The returned array can be recycled with ArrayFactor.DOUBLES_FACTORY.recycle(arr).
-
parameterizationCheck
public static void parameterizationCheck(int size, double[] uk) throws ParameterException
Check the array of parameterization values and reports any problems by throwing a ParameterException.- Parameters:
size
- The number of parameters in the array.uk
- The array of parameterization values to check.- Throws:
ParameterException
- if there is a problem with the parameterization array.
-
buildInterpKnotVector
public static KnotVector buildInterpKnotVector(double[] uk, int numPoints, int p)
Create a vector of knots to go with the list of parameter values for a curve that passes through a list of points. This uses the knot averaging technique.- Parameters:
uk
- The parameter values for each point in the curve. May not be null.numPoints
- The total number of points in the curve (and parameter array).p
- The degree of the NURBS curve.- Returns:
- A vector of knots of degree p that are parameterized for use with the input list of point parameter values.
-
approxPoints
public static BasicNurbsCurve approxPoints(int degree, int nCP, PointString<? extends GeomPoint> points) throws java.lang.IllegalArgumentException, org.apache.commons.math3.linear.SingularMatrixException, ParameterException
Create aNurbsCurve
of the specified degree that approximates, in a least squared error sense, the specified list of geometry points in the input order. This is a global approximation of the points, meaning that if one of the input points is moved, it will affect the entire curve, not just the local portion near the point.- Parameters:
degree
- The degree of the NURBS curve to create (must be > 0 and < the number of data points).nCP
- The number of control points in the new curve (must be > 1 and < the number of data points).points
- The string of GeomPoint objects to be approximated by the curve. May not be null.- Returns:
- A NurbsCurve approximation to the input list of points.
- Throws:
org.apache.commons.math3.linear.SingularMatrixException
- if the decomposed matrix is singular.java.lang.IllegalArgumentException
- if the any of the inputs is invalid.ParameterException
- See Also:
fitPoints(int, geomss.geom.PointString<? extends geomss.geom.GeomPoint>)
-
-