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 BasicNurbsCurve
copy()
Returns a copy of thisBasicNurbsCurve
instanceallocated
by the calling thread (possibly on the stack).BasicNurbsCurve
copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).boolean
equals(java.lang.Object obj)
Compares this BasicNurbsCurve against the specified object for strict equality (same values and same units).Point
getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).Point
getBoundsMin()
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.int
getDegree()
Return the degree of the NURBS curve.KnotVector
getKnotVector()
Return the knot vector of this curve.int
getPhyDimension()
Returns the number of physical dimensions of the geometry element.Point
getRealPoint(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 from0
tograde
with 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.int
hashCode()
Returns the hash code for this parameter.BasicNurbsCurve
immutable()
Return an immutable version of this NURBS curve.static BasicNurbsCurve
newInstance(ControlPoint[] cps, int degree, double... uK)
Create a NURBS curve from the given control points, knots and degree.static BasicNurbsCurve
newInstance(java.util.List<ControlPoint> cpList, KnotVector uKnots)
Generate a NURBS curve from the given control points and the given knot vector.static void
recycle(BasicNurbsCurve instance)
Recycles aBasicNurbsCurve
instance immediately (on the stack when executing in a StackContext).void
reset()
Resets the internal state of this object to its default values.int
size()
Returns the number of child-elements that make up this geometry element.BasicNurbsCurve
to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the equivalent to this curve but stated in the specified unit.BasicNurbsCurve
toDimension(int newDim)
Return the equivalent of this curve converted to the specified number of physical dimensions.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.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:
size
in 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:
getPhyDimension
in 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:
getControlPoints
in classNurbsCurve
- Returns:
- the ordered control points
-
getKnotVector
public KnotVector getKnotVector()
Return the knot vector of this curve.- Specified by:
getKnotVector
in classNurbsCurve
- Returns:
- The knot vector.
-
getDegree
public int getDegree()
Return the degree of the NURBS curve.- Specified by:
getDegree
in 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:
getRealPoint
in 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 from0
tograde
with 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:
getSDerivatives
in 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:
getBoundsMin
in 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:
getBoundsMax
in 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:
getUnit
in 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:
to
in interfaceCurve<NurbsCurve>
- Specified by:
to
in interfaceGeomElement<NurbsCurve>
- Specified by:
to
in 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:
toDimension
in interfaceCurve<NurbsCurve>
- Specified by:
toDimension
in interfaceGeomElement<NurbsCurve>
- Specified by:
toDimension
in 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 thisBasicNurbsCurve
instanceallocated
by the calling thread (possibly on the stack).- Specified by:
copy
in interfaceCurve<NurbsCurve>
- Specified by:
copy
in interfaceGeomElement<NurbsCurve>
- Specified by:
copy
in interfaceParametricGeometry<NurbsCurve>
- Specified by:
copy
in 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:
copyToReal
in interfaceCurve<NurbsCurve>
- Specified by:
copyToReal
in 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:
immutable
in 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:
reset
in interfacejavolution.lang.Reusable
- Overrides:
reset
in 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:
equals
in classAbstractGeomElement<NurbsCurve>
- Parameters:
obj
- the object to compare with.- Returns:
true
if this object is identical to that object;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
hashCode
in 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:
toText
in interfaceGeomElement<NurbsCurve>
- Overrides:
toText
in classNurbsCurve
- Returns:
- the text representation of this geometry element.
-
recycle
public static void recycle(BasicNurbsCurve instance)
Recycles aBasicNurbsCurve
instance immediately (on the stack when executing in a StackContext).- Parameters:
instance
- The instance to be recycled.
-
-