Class BasicNurbsCurve

    • 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 curve
        uK - 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 interface GeomElement<NurbsCurve>
        Returns:
        The number of control points in this curve.
      • getDegree

        public int getDegree()
        Return the degree of the NURBS curve.
        Specified by:
        getDegree in class NurbsCurve
        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 interface Curve<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 from 0 to grade 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 interface Curve<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 interface GeomElement<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 interface GeomElement<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 interface GeomElement<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 interface Curve<NurbsCurve>
        Specified by:
        to in interface GeomElement<NurbsCurve>
        Specified by:
        to in interface ParametricGeometry<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 interface Curve<NurbsCurve>
        Specified by:
        toDimension in interface GeomElement<NurbsCurve>
        Specified by:
        toDimension in interface ParametricGeometry<NurbsCurve>
        Parameters:
        newDim - The dimension of the curve to return.
        Returns:
        The equivalent of this curve converted to the new dimensions.
      • immutable

        public BasicNurbsCurve immutable()
        Return an immutable version of this NURBS curve. This implementation simply returns this BasicNurbsCurve instance.
        Specified by:
        immutable in class NurbsCurve
        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 interface javolution.lang.Reusable
        Overrides:
        reset in class AbstractGeomElement<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 class AbstractGeomElement<NurbsCurve>
        Parameters:
        obj - the object to compare with.
        Returns:
        true if this object is identical to that object; false otherwise.
      • 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 interface GeomElement<NurbsCurve>
        Overrides:
        toText in class NurbsCurve
        Returns:
        the text representation of this geometry element.
      • recycle

        public static void recycle​(BasicNurbsCurve instance)
        Recycles a BasicNurbsCurve instance immediately (on the stack when executing in a StackContext).
        Parameters:
        instance - The instance to be recycled.