Package geomss.geom.nurbs
Class BasicNurbsCurve
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<T>
-
- geomss.geom.AbstractCurve<NurbsCurve>
-
- geomss.geom.nurbs.NurbsCurve
-
- geomss.geom.nurbs.BasicNurbsCurve
-
- All Implemented Interfaces:
Curve<NurbsCurve>,GeomElement<NurbsCurve>,ParametricGeometry<NurbsCurve>,Transformable<NurbsCurve>,java.io.Serializable,java.lang.Cloneable,java.lang.Comparable,javolution.lang.Immutable,javolution.lang.Reusable,javolution.lang.ValueType,javolution.xml.XMLSerializable
public final class BasicNurbsCurve extends NurbsCurve implements javolution.lang.ValueType
A basic implementation of a parametric NURBS curve.Modified by: Joseph A. Huwaldt
- Version:
- November 28, 2015
- Author:
- Samuel Gerber, Date: May 14, 2009, Version 1.0.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractCurve
GTOL
-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BasicNurbsCurvecopy()Returns a copy of thisBasicNurbsCurveinstanceallocatedby the calling thread (possibly on the stack).BasicNurbsCurvecopyToReal()Return a copy of this object with any transformations or subranges removed (applied).booleanequals(java.lang.Object obj)Compares this BasicNurbsCurve against the specified object for strict equality (same values and same units).PointgetBoundsMax()Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).PointgetBoundsMin()Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).java.util.List<ControlPoint>getControlPoints()Return a list of control points for this curve.intgetDegree()Return the degree of the NURBS curve.KnotVectorgetKnotVector()Return the knot vector of this curve.intgetPhyDimension()Returns the number of physical dimensions of the geometry element.PointgetRealPoint(double s)Calculate a point on the curve for the given parametric distance along the curve,p(s).java.util.List<Vector<javax.measure.quantity.Length>>getSDerivatives(double s, int grade)Calculate all the derivatives from0togradewith respect to parametric distance on the curve for the given parametric distance along the curve,d^{grade}p(s)/d^{grade}s.javax.measure.unit.Unit<javax.measure.quantity.Length>getUnit()Returns the unit in which the control points in this curve are stated.inthashCode()Returns the hash code for this parameter.BasicNurbsCurveimmutable()Return an immutable version of this NURBS curve.static BasicNurbsCurvenewInstance(ControlPoint[] cps, int degree, double... uK)Create a NURBS curve from the given control points, knots and degree.static BasicNurbsCurvenewInstance(java.util.List<ControlPoint> cpList, KnotVector uKnots)Generate a NURBS curve from the given control points and the given knot vector.static voidrecycle(BasicNurbsCurve instance)Recycles aBasicNurbsCurveinstance immediately (on the stack when executing in a StackContext).voidreset()Resets the internal state of this object to its default values.intsize()Returns the number of child-elements that make up this geometry element.BasicNurbsCurveto(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)Returns the equivalent to this curve but stated in the specified unit.BasicNurbsCurvetoDimension(int newDim)Return the equivalent of this curve converted to the specified number of physical dimensions.javolution.text.TexttoText()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.nurbs.NurbsCurve
getArcLength, getArcLength, getTransformed, gridToTolerance, insertKnot, intersect, isDegenerate, isLine, isPlanar, isValid, mergeKnotVector, refineKnotVector, refineKnotVector, removeKnot, reverse, splitAt, toNurbs, toNurbs
-
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, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toString
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
-
-
-
-
Method Detail
-
newInstance
public static BasicNurbsCurve newInstance(ControlPoint[] cps, int degree, double... uK)
Create a NURBS curve from the given control points, knots and degree.- Parameters:
cps- Array of control points. May not be null.degree- Degree of the NURBS curveuK- Knot values. May not be null.- Returns:
- A new NURBS curve
- Throws:
java.lang.IllegalArgumentException- if the knot vector is not valid.
-
newInstance
public static BasicNurbsCurve newInstance(java.util.List<ControlPoint> cpList, KnotVector uKnots)
Generate a NURBS curve from the given control points and the given knot vector.- Parameters:
cpList- List of control points. May not be null.uKnots- Knot vector for the curve. May not be null.- Returns:
- A new NURBS curve.
- Throws:
java.lang.IllegalArgumentException- if the knot vector is not consistent with the number of control points.
-
size
public int size()
Returns the number of child-elements that make up this geometry element. This implementation returns the number of control points in this NURBS curve.- Specified by:
sizein interfaceGeomElement<NurbsCurve>- Returns:
- The number of control points in this curve.
-
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of the geometry element.- Specified by:
getPhyDimensionin interfaceGeomElement<NurbsCurve>- Returns:
- The number of physical dimensions of this geometry element.
-
getControlPoints
public java.util.List<ControlPoint> getControlPoints()
Return a list of control points for this curve.- Specified by:
getControlPointsin classNurbsCurve- Returns:
- the ordered control points
-
getKnotVector
public KnotVector getKnotVector()
Return the knot vector of this curve.- Specified by:
getKnotVectorin classNurbsCurve- Returns:
- The knot vector.
-
getDegree
public int getDegree()
Return the degree of the NURBS curve.- Specified by:
getDegreein classNurbsCurve- Returns:
- degree of curve
-
getRealPoint
public Point getRealPoint(double s)
Calculate a point on the curve for the given parametric distance along the curve,p(s).- Specified by:
getRealPointin interfaceCurve<NurbsCurve>- Parameters:
s- parametric distance to calculate a point for (0.0 to 1.0 inclusive).- Returns:
- the calculated point
-
getSDerivatives
public java.util.List<Vector<javax.measure.quantity.Length>> getSDerivatives(double s, int grade)
Calculate all the derivatives from0togradewith respect to parametric distance on the curve for the given parametric distance along the curve,d^{grade}p(s)/d^{grade}s.Example:
1st derivative (grade = 1), this returns[p(s), dp(s)/ds];
2nd derivative (grade = 2), this returns[p(s), dp(s)/ds, d^2p(s)/d^2s]; etc.- Specified by:
getSDerivativesin interfaceCurve<NurbsCurve>- Parameters:
s- Parametric distance to calculate derivatives for (0.0 to 1.0 inclusive).grade- The maximum grade to calculate the derivatives for (1=1st derivative, 2=2nd derivative, etc)- Returns:
- A list of derivatives up to the specified grade of the curve at the specified parametric position.
- Throws:
java.lang.IllegalArgumentException- if the grade is < 0.
-
getBoundsMin
public Point getBoundsMin()
Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).- Specified by:
getBoundsMinin interfaceGeomElement<NurbsCurve>- Returns:
- The minimum bounding box coordinate for this geometry element.
- Throws:
java.lang.IndexOutOfBoundsException- if this list contains no geometry.
-
getBoundsMax
public Point getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).- Specified by:
getBoundsMaxin interfaceGeomElement<NurbsCurve>- Returns:
- The maximum bounding box coordinate for this geometry element.
- Throws:
java.lang.IndexOutOfBoundsException- if this list contains no elements.
-
getUnit
public javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
Returns the unit in which the control points in this curve are stated.- Specified by:
getUnitin interfaceGeomElement<NurbsCurve>- Returns:
- The unit that this curves points are stated in.
-
to
public BasicNurbsCurve to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this curve but stated in the specified unit.- Specified by:
toin interfaceCurve<NurbsCurve>- Specified by:
toin interfaceGeomElement<NurbsCurve>- Specified by:
toin interfaceParametricGeometry<NurbsCurve>- Parameters:
unit- The length unit of the curve to be returned. May not be null.- Returns:
- An equivalent to this curve but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException- if the the input unit is not a length unit.
-
toDimension
public BasicNurbsCurve toDimension(int newDim)
Return the equivalent of this curve converted to the specified number of physical dimensions. If the number of dimensions is greater than this element, then zeros are added to the additional dimensions. If the number of dimensions is less than this element, then the extra dimensions are simply dropped (truncated). If the new dimensions are the same as the dimension of this element, then this element is simply returned.- Specified by:
toDimensionin interfaceCurve<NurbsCurve>- Specified by:
toDimensionin interfaceGeomElement<NurbsCurve>- Specified by:
toDimensionin interfaceParametricGeometry<NurbsCurve>- Parameters:
newDim- The dimension of the curve to return.- Returns:
- The equivalent of this curve converted to the new dimensions.
-
copy
public BasicNurbsCurve copy()
Returns a copy of thisBasicNurbsCurveinstanceallocatedby the calling thread (possibly on the stack).- Specified by:
copyin interfaceCurve<NurbsCurve>- Specified by:
copyin interfaceGeomElement<NurbsCurve>- Specified by:
copyin interfaceParametricGeometry<NurbsCurve>- Specified by:
copyin interfacejavolution.lang.ValueType- Returns:
- an identical and independent copy of this object.
-
copyToReal
public BasicNurbsCurve copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Specified by:
copyToRealin interfaceCurve<NurbsCurve>- Specified by:
copyToRealin interfaceGeomElement<NurbsCurve>- Returns:
- A copy of this object with any transformations or subranges removed (applied).
-
immutable
public BasicNurbsCurve immutable()
Return an immutable version of this NURBS curve. This implementation simply returns this BasicNurbsCurve instance.- Specified by:
immutablein classNurbsCurve- Returns:
- an immutable version of this curve.
-
reset
public void reset()
Resets the internal state of this object to its default values.- Specified by:
resetin interfacejavolution.lang.Reusable- Overrides:
resetin classAbstractGeomElement<NurbsCurve>
-
equals
public boolean equals(java.lang.Object obj)
Compares this BasicNurbsCurve against the specified object for strict equality (same values and same units).- Overrides:
equalsin classAbstractGeomElement<NurbsCurve>- Parameters:
obj- the object to compare with.- Returns:
trueif this object is identical to that object;falseotherwise.
-
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
hashCodein classAbstractGeomElement<NurbsCurve>- Returns:
- the hash code value.
-
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:
toTextin interfaceGeomElement<NurbsCurve>- Overrides:
toTextin classNurbsCurve- Returns:
- the text representation of this geometry element.
-
recycle
public static void recycle(BasicNurbsCurve instance)
Recycles aBasicNurbsCurveinstance immediately (on the stack when executing in a StackContext).- Parameters:
instance- The instance to be recycled.
-
-