Class BSplineCurve3f

    • Field Detail

      • m_iNumCtrlPoints

        protected int m_iNumCtrlPoints
        Larger than basis control points, because of replication
      • m_akCtrlPoint

        protected Vector3f[] m_akCtrlPoint
        Set of control points
      • m_bLoop

        protected boolean m_bLoop
        Loop flag
      • m_iReplicate

        protected int m_iReplicate
        the number of replicated control points
    • Constructor Detail

      • BSplineCurve3f

        public BSplineCurve3f​(int iNumCtrlPoints,
                              Vector3f[] akCtrlPoint,
                              int iDegree,
                              boolean bLoop,
                              boolean bOpen)
        Construction and destruction. The caller is responsible for deleting the input arrays if they were dynamically allocated. Internal copies of the arrays are made, so to dynamically change control points or knots you must use the 'SetControlPoint', 'GetControlPoint', and 'Knot' member functions. Uniform spline. The number of control points is n+1 >= 2. The degree of the B-spline is d and must satisfy 1 t[i] = 0, 0 <= i <= d (i-d)/(n+1-d), d+1 <= i <= n 1, n+1 <= i <= n+d+1 If bOpen is 'false', the spline is periodic and the knots are
               t[i] = (i-d)/(n+1-d),   0 <= i <= n+d+1
         
        If bLoop is 'true', extra control points are added to generate a closed curve. For an open spline, the control point array is reallocated and one extra control point is added, set to the first control point C[n+1] = C[0]. For a periodic spline, the control point array is reallocated and the first d points are replicated. In either case the knot array is calculated accordingly.
        Parameters:
        iNumCtrlPoints - number of control points is n+1 >= 2
        akCtrlPoint - control point array
        iDegree - degree of the B-spline is d and must satisfy 1
        bLoop - true to generate a closed loop
        bOpen - true for open, false for periodic
      • BSplineCurve3f

        public BSplineCurve3f​(int iNumCtrlPoints,
                              Vector3f[] akCtrlPoint,
                              int iDegree,
                              boolean bLoop,
                              float[] afKnot)
        Open, nonuniform spline. The knot array must have n-d elements. The elements must be nondecreasing. Each element must be in [0,1].
        Parameters:
        iNumCtrlPoints - number of control points is n+1 >= 2
        akCtrlPoint - control point array
        iDegree - degree of the B-spline is d and must satisfy 1
        bLoop - true to generate a closed loop
        afKnot - knot array
    • Method Detail

      • CreateApproximation

        public static BSplineCurve3f CreateApproximation​(float[] akValue,
                                                         int iNumControlPoints,
                                                         int iDegree)
        Create a BSpline curve which best fits a set of 3D points.
        Parameters:
        akValue - float[] Array of values. The order of the points in the array defines a path.
        iNumControlPoints - int Number of control points to use when creating the BSpline curve. The location of the control points are determined to provide a least squares best fit.
        iDegree - int Degree of the basis functions to use when creating the BSpline curve.
        Returns:
        BSplineCurve3 New instance of the best fit BSpline curve. Even though the fit is for a single set of values, the curve that is created is for 3D set of values in which the x coordinates are used to representing the single value curve. The y and z coordinates are undefined.
      • CreateApproximation

        public static BSplineCurve3f CreateApproximation​(Vector3f[] akPoint,
                                                         int iNumControlPoints,
                                                         int iDegree)
        Create a BSpline curve which best fits a set of 3D points.
        Parameters:
        akPoint - Point3f[] Array of 3D points. The order of the points in the array defines a path.
        iNumControlPoints - Number of 3D control points to use when creating the BSpline curve. The location of the 3D control points are determined to provide a least squares best fit.
        iDegree - Degree of the basis functions to use when creating the BSpline curve.
        Returns:
        BSplineCurve3 New instance of the best fit BSpline curve.
      • dispose

        public void dispose()
        release resources
      • Get

        public void Get​(float fTime,
                        Vector3f pkPos,
                        Vector3f pkDer1,
                        Vector3f pkDer2,
                        Vector3f pkDer3)
        If you need position and derivatives at the same time, it is more efficient to call these functions. Pass the addresses of those quantities whose values you want. You may pass null in any argument whose value you do not want.
        Parameters:
        fTime - time
        pkPos - output position
        pkDer1 - output first derivative
        pkDer2 - output second derivative
        pkDer3 - output third derivative
      • GetBasis

        public BSplineBasisf GetBasis()
        Access the basis function to compute it without control points. This is useful for least squares fitting of curves.
        Returns:
        reference to basis
      • GetControlPoint

        public Vector3f GetControlPoint​(int i)
        Retrieve a control point. The input index should be valid (0
        Parameters:
        i - index return control point
        • GetDegree

          public int GetDegree()
          Returns:
          polynomial degree
        • GetFirstDerivative

          public Vector3f GetFirstDerivative​(float fTime)
          Description copied from class: Curve3f
          Get the 3D coordinates of the 1st derivative vector at the point along the curve evaluated for the input time value.
          Specified by:
          GetFirstDerivative in class Curve3f
          Parameters:
          fTime - Input time value which must be within the range for which this curve is defined.
          Returns:
          New instance created to contain the 3D coordinates of the computed 1st derivative vector. If the time value is less than getMinTime() then the 1st derivative vector at the start of the curve is returned. If the time value is greater than getMaxTime() then the 1st derivative vector at the end of the curve is returned.
          See Also:
          GetPosition(float fTime)
        • GetKnot

          public float GetKnot​(int i)
        • GetNumCtrlPoints

          public int GetNumCtrlPoints()
          Returns:
          number of control points
        • GetPosition

          public Vector3f GetPosition​(float fTime)
          The spline is defined for 0 1, t is set to 1; if t
          Specified by:
          GetPosition in class Curve3f
          Parameters:
          fTime - time
          Returns:
          New instance created to contain the 3D coordinates of the computed position. If the time value is less than getMinTime() then the coordinates of the point at the start of the curve is returned. If the time value is greater than getMaxTime() then the coordinates of the point at the end of the curve is returned.
          • GetSecondDerivative

            public Vector3f GetSecondDerivative​(float fTime)
            Description copied from class: Curve3f
            Get the 3D coordinates of the 2nd derivative vector at the point along the curve evaluated for the input time value.
            Specified by:
            GetSecondDerivative in class Curve3f
            Parameters:
            fTime - Input time value which must be within the range for which this curve is defined.
            Returns:
            New instance created to contain the 3D coordinates of the computed 1st derivative vector. If the time value is less than getMinTime() then the 2nd derivative vector at the start of the curve is returned. If the time value is greater than getMaxTime() then the 2nd derivative vector at the end of the curve is returned.
            See Also:
            GetPosition(float)
          • IsLoop

            public boolean IsLoop()
            Returns:
            loop flag
          • IsOpen

            public boolean IsOpen()
            Returns:
            Open flag
          • IsUniform

            public boolean IsUniform()
            Returns:
            Uniform flag
          • SetControlPoint

            public void SetControlPoint​(int i,
                                        Vector3f rkCtrl)
            Control points may be changed at any time. The input index should be valid (0
            Parameters:
            i - index
            rkCtrl - new control point
            • SetKnot

              public void SetKnot​(int i,
                                  float fKnot)
              The knot values can be changed only if the basis function is nonuniform and the input index is valid (0
              Parameters:
              i - index
              fKnot - new knot
              • CreateControl

                private void CreateControl​(Vector3f[] akCtrlPoint)
                Allocate our control points, with replication
                Parameters:
                akCtrlPoint - starting points