Package geomss.geom.nurbs
Class NurbsCurve
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<T>
-
- geomss.geom.AbstractCurve<NurbsCurve>
-
- geomss.geom.nurbs.NurbsCurve
-
- All Implemented Interfaces:
Curve<NurbsCurve>
,GeomElement<NurbsCurve>
,ParametricGeometry<NurbsCurve>
,Transformable<NurbsCurve>
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,javolution.lang.Reusable
,javolution.xml.XMLSerializable
- Direct Known Subclasses:
BasicNurbsCurve
,NurbsCurveTrans
public abstract class NurbsCurve extends AbstractCurve<NurbsCurve>
The interface and implementation in common to all NURBS curves.Modified by: Joseph A. Huwaldt
- Version:
- February 17, 2025
- Author:
- Joseph A. Huwaldt, Date: May 28, 2009
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractCurve
GTOL
-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Constructor Summary
Constructors Constructor Description NurbsCurve()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Parameter<javax.measure.quantity.Length>
getArcLength(double eps)
Return the total arc length of this curve.Parameter<javax.measure.quantity.Length>
getArcLength(double s1, double s2, double eps)
Return the arc length of a segment of this curve.abstract java.util.List<ControlPoint>
getControlPoints()
Return a list of control points for this curve.abstract int
getDegree()
Return the degree of the NURBS curve.abstract KnotVector
getKnotVector()
Return the knot vector of this curve.NurbsCurveTrans
getTransformed(GTransform transform)
Returns transformed version of this element.PointString<SubrangePoint>
gridToTolerance(Parameter<javax.measure.quantity.Length> tol)
Return a string of points that are gridded onto the curve with the number of points and spacing chosen to result in straight line segments between the points that have mid-points that are all within the specified tolerance of this curve.abstract BasicNurbsCurve
immutable()
Return an immutable version of this NURBS curve.BasicNurbsCurve
insertKnot(double s, int numInsertions)
Create and return a newNURBS curve
that is geometrically identical to this one but with a new knot inserted at the specified parametric location.GeomList<PointString<SubrangePoint>>
intersect(LineSegment line, Parameter<javax.measure.quantity.Length> tol)
Return the intersection between a line segment and this curve.boolean
isDegenerate(Parameter<javax.measure.quantity.Length> tol)
Returntrue
if this curve is degenerate (i.e.: has length less than the specified tolerance).boolean
isLine(Parameter<javax.measure.quantity.Length> tol)
Returnstrue
if this curve is a line to within the specified tolerance.boolean
isPlanar(Parameter<javax.measure.quantity.Length> tol)
Returntrue
if this curve is planar orfalse
if it is not.boolean
isValid()
Returntrue
if this NurbsCurve contains valid and finite numerical components.NurbsCurve
mergeKnotVector(Float64Vector Um)
Return aNURBS curve
that is geometrically identical to this one but with the specified list of knots merged into it's knot vector.BasicNurbsCurve
refineKnotVector(double[] newKnots)
Create and return a newNURBS curve
that is geometrically identical to this one but with the specified list of knots inserted into it's knot vector.BasicNurbsCurve
refineKnotVector(Float64Vector newKnots)
Create and return a newNURBS curve
that is geometrically identical to this one but with the specified list of knots inserted into it's knot vector.NurbsCurve
removeKnot(int index, int numRemovals, Parameter<javax.measure.quantity.Length> tolerance)
Attempts to remove the knot with the specified index from this NURBS curve the specified number of times.NurbsCurve
reverse()
Return a new curve that is identical to this one, but with the parameterization reversed.GeomList<NurbsCurve>
splitAt(double s)
Split thisNurbsCurve
at the specified parametric position returning a list containing two curves (a lower curve with smaller parametric positions than "s" and an upper curve with larger parametric positions).NurbsCurve
toNurbs()
Return a NURBS curve representation of this curve.NurbsCurve
toNurbs(Parameter<javax.measure.quantity.Length> tol)
Return a NURBS curve representation of this curve to within the specified tolerance.javolution.text.Text
toText()
Returns the text representation of this geometry element that consists of the name followed by the control point values, followed by the knot vector.-
Methods inherited from class geomss.geom.AbstractCurve
extractGrid, getArcLength, getBinormal, getBinormal, getClosest, getClosest, getClosest, getClosest, getClosest, getClosest, getCurvature, getCurvature, getDerivatives, getEnclosedArea, getFarthest, getFarthest, getFarthest, getLimitPoint, getParDimension, getPoint, getPoint, getPointAtArcLength, getPrincipalNormal, getPrincipalNormal, getRealPoint, getSDerivative, getSDerivatives, getTangencyPoint, getTangent, getTangent, getTorsion, getTorsion, getVariationOfCurvature, getVariationOfCurvature, intersect, intersect, intersect, intersect, isCircular, splitAt
-
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, equals, getAllUserData, getID, getName, getUserData, hashCode, putAllUserData, putUserData, removeChangeListener, removeUserData, reset, setName, toString
-
Methods inherited from interface geomss.geom.Curve
copy, copyToReal, getRealPoint, getSDerivatives, to, toDimension
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getBoundsMax, getBoundsMin, getID, getName, getPhyDimension, getUnit, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, size
-
-
-
-
Constructor Detail
-
NurbsCurve
public NurbsCurve()
-
-
Method Detail
-
getControlPoints
public abstract java.util.List<ControlPoint> getControlPoints()
Return a list of control points for this curve.- Returns:
- the ordered control points
-
getKnotVector
public abstract KnotVector getKnotVector()
Return the knot vector of this curve.- Returns:
- The knot vector.
-
getDegree
public abstract int getDegree()
Return the degree of the NURBS curve.- Returns:
- degree of curve
-
immutable
public abstract BasicNurbsCurve immutable()
Return an immutable version of this NURBS curve.- Returns:
- an immutable version of this curve.
-
reverse
public NurbsCurve reverse()
Return a new curve that is identical to this one, but with the parameterization reversed.- Returns:
- A new curve that is identical to this one but with the parameterization reversed.
-
insertKnot
public BasicNurbsCurve insertKnot(double s, int numInsertions)
Create and return a newNURBS curve
that is geometrically identical to this one but with a new knot inserted at the specified parametric location. The parameterization of the new curve is identical to this curve, but the new curve will have a new knot at the specified location and a new set of control points.- Parameters:
s
- The parametric location where the knot is to be inserted.numInsertions
- The number of times that the knot should be inserted at the specified position.- Returns:
- A new NURBS curve that is identical to this one, but with a new knot inserted at the specified location.
-
refineKnotVector
public BasicNurbsCurve refineKnotVector(double[] newKnots)
Create and return a newNURBS curve
that is geometrically identical to this one but with the specified list of knots inserted into it's knot vector. The parameterization of the new curve is identical to this curve, but the new curve will have the new knots at the specified locations and a new set of control points. This is more efficient than repeatedly calling insertKnot() for multiple knot insertions.- Parameters:
newKnots
- The parametric locations where the knots are to be inserted.- Returns:
- A new NURBS curve that is identical to this one, but with the new knots inserted at the specified locations.
-
refineKnotVector
public BasicNurbsCurve refineKnotVector(Float64Vector newKnots)
Create and return a newNURBS curve
that is geometrically identical to this one but with the specified list of knots inserted into it's knot vector. The parameterization of the new curve is identical to this curve, but the new curve will have the new knots at the specified locations and a new set of control points. This is more efficient than repeatedly calling insertKnot() for multiple knot insertions.- Parameters:
newKnots
- The parametric locations where the knots are to be inserted. May not be null.- Returns:
- A new NURBS curve that is identical to this one, but with the new knots inserted at the specified locations.
-
mergeKnotVector
public NurbsCurve mergeKnotVector(Float64Vector Um)
Return aNURBS curve
that is geometrically identical to this one but with the specified list of knots merged into it's knot vector. The parameterization of the new curve is identical to this curve, but the new curve will have any new knots at the specified locations added and a new set of control points. If the input knot list matches the knot list of this curve, then this curve is returned.- Parameters:
Um
- The knot vector to merge with this curve's knot vector. May not be null.- Returns:
- A NURBS curve that is identical to this one, but with the merger of the input knot vector and this curve's knot vector.
-
removeKnot
public NurbsCurve removeKnot(int index, int numRemovals, Parameter<javax.measure.quantity.Length> tolerance)
Attempts to remove the knot with the specified index from this NURBS curve the specified number of times. If the knot can not be removed without changing the shape of the curve, then a reference to this curve is returned:if (crv == crv.removeKnot(...)) { no knots removed }
.- Parameters:
index
- The index of the knot to be removed (degree + 1 ≤ index < knot vector length - degree).numRemovals
- The number of times that the knot at "index" should be removed (1 ≤ num ≤ multiplicity of the knot). If numRemovals is > multiplicity of the knot, then numRemovals is set to the multiplicity of the knot.tolerance
- The knot(s) specified will be removed as long as the deviation of the curve is everywhere less than this tolerance. May not be null.- Returns:
- A new NURBS curve that is identical to this one (to within the specified tolerance), but with the specified knot removed or a reference to this curve if the knot could not be removed.
-
getArcLength
public Parameter<javax.measure.quantity.Length> getArcLength(double eps)
Return the total arc length of this curve.- Specified by:
getArcLength
in interfaceCurve<NurbsCurve>
- Overrides:
getArcLength
in classAbstractCurve<NurbsCurve>
- Parameters:
eps
- The desired fractional accuracy on the arc-length.- Returns:
- The total arc length of the curve.
-
getArcLength
public Parameter<javax.measure.quantity.Length> getArcLength(double s1, double s2, double eps)
Return the arc length of a segment of this curve.- Specified by:
getArcLength
in interfaceCurve<NurbsCurve>
- Overrides:
getArcLength
in classAbstractCurve<NurbsCurve>
- Parameters:
s1
- The starting parametric distance along the curve to begin the arc-length calculation from.s2
- The ending parametric distance along the curve to end the arc-length calculation at.eps
- The desired fractional accuracy on the arc-length.- Returns:
- The arc length of the specified segment of the curve.
-
gridToTolerance
public PointString<SubrangePoint> gridToTolerance(Parameter<javax.measure.quantity.Length> tol)
Return a string of points that are gridded onto the curve with the number of points and spacing chosen to result in straight line segments between the points that have mid-points that are all within the specified tolerance of this curve.- Specified by:
gridToTolerance
in interfaceCurve<NurbsCurve>
- Overrides:
gridToTolerance
in classAbstractCurve<NurbsCurve>
- Parameters:
tol
- The maximum distance that a straight line between gridded points may deviate from this curve. May not be null.- Returns:
- A string of subrange points gridded onto the curve.
-
getTransformed
public NurbsCurveTrans getTransformed(GTransform transform)
Returns transformed version of this element. The returned object implementsGeomTransform
and contains this element as a child.- Parameters:
transform
- The transformation to apply to this geometry. May not be null.- Returns:
- A new triangle that is identical to this one with the specified transformation applied.
- Throws:
DimensionException
- if this point is not 3D.
-
splitAt
public GeomList<NurbsCurve> splitAt(double s)
Split thisNurbsCurve
at the specified parametric position returning a list containing two curves (a lower curve with smaller parametric positions than "s" and an upper curve with larger parametric positions).- Parameters:
s
- The parametric position where this curve should be split (must not be 0 or 1!).- Returns:
- A list containing two curves: 0 == the lower curve, 1 == the upper curve.
-
intersect
public GeomList<PointString<SubrangePoint>> intersect(LineSegment line, Parameter<javax.measure.quantity.Length> tol)
Return the intersection between a line segment and this curve.- Specified by:
intersect
in interfaceCurve<NurbsCurve>
- Overrides:
intersect
in classAbstractCurve<NurbsCurve>
- Parameters:
line
- The line segment to intersect. May not be null.tol
- Tolerance (in physical space) to refine the point positions to. May not be null.- Returns:
- A list containing two PointString instances each containing zero or more subrange points, on this curve and the input line segment respectively, made by the intersection of this curve with the specified line segment. If no intersections are found a list of two empty PointStrings are returned.
-
toNurbs
public NurbsCurve toNurbs(Parameter<javax.measure.quantity.Length> tol)
Return a NURBS curve representation of this curve to within the specified tolerance. This implementation returns a reference to this curve itself since it is already a NURBS curve and the tolerance parameter is ignored.- Parameters:
tol
- Ignored. May passnull
.- Returns:
- A reference to this NURBS curve is returned.
-
toNurbs
public NurbsCurve toNurbs()
Return a NURBS curve representation of this curve. This implementation returns a reference to this curve itself since it is already a NURBS curve.- Returns:
- A reference to this NURBS curve is returned.
-
isValid
public boolean isValid()
Returntrue
if this NurbsCurve contains valid and finite numerical components. A value offalse
will be returned if any of the control point values or knots are NaN or Inf.- Returns:
- true if this curve contains valid and finite values.
-
isDegenerate
public boolean isDegenerate(Parameter<javax.measure.quantity.Length> tol)
Returntrue
if this curve is degenerate (i.e.: has length less than the specified tolerance).- Specified by:
isDegenerate
in interfaceCurve<NurbsCurve>
- Specified by:
isDegenerate
in interfaceParametricGeometry<NurbsCurve>
- Overrides:
isDegenerate
in classAbstractCurve<NurbsCurve>
- Parameters:
tol
- The tolerance for determining if this curve is degenerate. May not be null.- Returns:
- true if this curve is degenerate.
- See Also:
getArcLength(double)
-
isLine
public boolean isLine(Parameter<javax.measure.quantity.Length> tol)
Returnstrue
if this curve is a line to within the specified tolerance.- Specified by:
isLine
in interfaceCurve<NurbsCurve>
- Overrides:
isLine
in classAbstractCurve<NurbsCurve>
- Parameters:
tol
- The tolerance for determining if this curve is a line. If null is passed, then exact linearity is required.- Returns:
- true if this curve is a line.
-
isPlanar
public boolean isPlanar(Parameter<javax.measure.quantity.Length> tol)
Returntrue
if this curve is planar orfalse
if it is not.- Specified by:
isPlanar
in interfaceCurve<NurbsCurve>
- Overrides:
isPlanar
in classAbstractCurve<NurbsCurve>
- Parameters:
tol
- The geometric tolerance to use in determining if the curve is planar. May not be null.- Returns:
- true if this curve is planar.
-
toText
public javolution.text.Text toText()
Returns the text representation of this geometry element that consists of the name followed by the control point values, followed by the knot vector. For example:{aCurve = {{{1 ft, 0 ft}, 1.0}, {{0 ft, 1 ft}, 0.25}, {{-1 ft, 0 ft}, 1.0}},{degree=2,{0.0, 0.0, 0.0, 1.0, 1.0, 1.0}}}
If there is no name, then the output looks like this:{{{{1 ft, 0 ft}, 1.0}, {{0 ft, 1 ft}, 0.25}, {{-1 ft, 0 ft}, 1.0}},{degree=2,{0.0, 0.0, 0.0, 1.0, 1.0, 1.0}}}
- Specified by:
toText
in interfaceGeomElement<NurbsCurve>
- Overrides:
toText
in classAbstractGeomElement<NurbsCurve>
- Returns:
- the text representation of this geometry element.
-
-