Class BSplineBasisf

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    BSplineBasisDiscretef

    public class BSplineBasisf
    extends java.lang.Object
    implements java.io.Serializable
    Basis functions for B-Splines
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      BSplineBasisf()
      Empty default constructor.
      BSplineBasisf​(int iNumCtrlPoints, int iDegree)
      Open uniform.
      BSplineBasisf​(int iNumCtrlPoints, int iDegree, boolean bOpen)
      Open uniform or periodic uniform.
      BSplineBasisf​(int iNumCtrlPoints, int iDegree, float[] afKnot)
      Open nonuniform.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private float[][] Allocate()
      Position and derivative storage allocation.
      int Compute​(float fU, float[] afBD0, float[] afBD1, float[] afBD2)
      Evaluate basis functions for the given input and return the knot index i for which knot[i] <= fU < knot[i+1].
      void Compute​(float fTime, int uiOrder, int[] riMinIndex, int[] riMaxIndex)
      evaluate basis functions and their derivatives
      void Create​(int iNumCtrlPoints, int iDegree, boolean bOpen)
      Open uniform or periodic uniform.
      void Create​(int iNumCtrlPoints, int iDegree, float[] afKnot)
      Open nonuniform.
      void dispose()
      release resources
      float GetD0​(int i)  
      float GetD1​(int i)  
      float GetD2​(int i)  
      float GetD3​(int i)  
      int GetDegree()  
      int GetKey​(float[] rfTime)
      Determine knot index i for which knot[i] <= rfTime < knot[i+1].
      float GetKnot​(int i)
      Knot access for nonuniform splines
      int GetKnotIndex​(float fU)
      Return the knot index i for which knot[i] <= fU < knot[i+1].
      static int GetMinNumControlPoints​(int iDegree)
      Given a BSpline degree, return the minimum number of control points that is required.
      int GetNumCtrlPoints()  
      private int Initialize​(int iNumCtrlPoints, int iDegree, boolean bOpen)
      Common initialization.
      boolean IsOpen()  
      boolean IsSameAs​(BSplineBasisf that)
      Return indication of whether two BSpline basis instances are the same.
      boolean IsUniform()  
      void SetKnot​(int i, float fKnot)
      Knot access for nonuniform splines
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_iNumCtrlPoints

        protected int m_iNumCtrlPoints
        n+1
      • m_iDegree

        protected int m_iDegree
        d
      • m_afKnot

        protected float[] m_afKnot
        knot[n+d+2]
      • m_iNumKnots

        protected int m_iNumKnots
        number of knots
      • m_bOpen

        protected boolean m_bOpen
        flags
      • m_bUniform

        protected boolean m_bUniform
        flags
      • m_aafBD0

        protected float[][] m_aafBD0
        Storage for the basis functions. The basis array is always allocated by the constructor calls. bd0[d+1][n+d+1]
      • m_aafBD1

        protected float[][] m_aafBD1
        Storage for first three derivatives. A derivative basis array is allocated on the first call to a derivative member function. bd1[d+1][n+d+1]
      • m_aafBD2

        protected float[][] m_aafBD2
        bd2[d+1][n+d+1]
      • m_aafBD3

        protected float[][] m_aafBD3
        bd3[d+1][n+d+1]
    • Constructor Detail

      • BSplineBasisf

        public BSplineBasisf()
        Empty default constructor. Call Create()...
      • BSplineBasisf

        public BSplineBasisf​(int iNumCtrlPoints,
                             int iDegree)
        Open uniform.
        Parameters:
        iNumCtrlPoints - number of spline control points, 2 or more.
        iDegree - polynomial degree, between 1 and iNumCtrlPoints - 1
        See Also:
        Create(int, int, boolean)
      • BSplineBasisf

        public BSplineBasisf​(int iNumCtrlPoints,
                             int iDegree,
                             boolean bOpen)
        Open uniform or periodic uniform.
        Parameters:
        iNumCtrlPoints - number of spline control points, 2 or more.
        iDegree - polynomial degree, between 1 and iNumCtrlPoints - 1
        bOpen - true for open uniform, false for periodic uniform.
        See Also:
        Create(int, int, boolean)
      • BSplineBasisf

        public BSplineBasisf​(int iNumCtrlPoints,
                             int iDegree,
                             float[] afKnot)
        Open nonuniform.
        Parameters:
        iNumCtrlPoints - number of spline control points, 2 or more.
        iDegree - polynomial degree, between 1 and iNumCtrlPoints - 1
        afKnot - The knot array must have n-d elements. The elements must be nondecreasing. Each element must be in [0,1].
        See Also:
        Create(int, int, float[])
    • Method Detail

      • GetMinNumControlPoints

        public static int GetMinNumControlPoints​(int iDegree)
        Given a BSpline degree, return the minimum number of control points that is required.
        Parameters:
        iDegree - Input degree of the BSpline.
        Returns:
        Minimum number of control points required.
      • Compute

        public int Compute​(float fU,
                           float[] afBD0,
                           float[] afBD1,
                           float[] afBD2)
        Evaluate basis functions for the given input and return the knot index i for which knot[i] <= fU < knot[i+1]. It is then that indexes i-degree <= k <= i have non-zero basis evaluations.
        Parameters:
        fU - float Input value in the [0,1] range. Clamped if not.
        afBD0 - float[] Array to be filled with position basis evaluation at each of the knot values for the given fU input. This array must have enough elements to store a value for each control point. This array must not be null.
        afBD1 - float[] Array to be filled with first derivative basis evaluation at each of the knot values for the given fU input. This array may be null meaning that the first derivative basis evaluation is not computed, but if the array is defined it must have enough elements to store a value for each control point. If this array is null, then the afBD2 array must also be null.
        afBD2 - float[] Array to be filled with second derivative basis evaluation at each of the knot values for the given fU input. This array may be null meaning that the second derivative basis evaluation is not computed, but if the array is defined it must have enough elements to store a value for each control point. If this array is not null, then the afBD1 array must not be null.
        Returns:
        The knot index i for which knot[i] <= fU < knot[i+1].
        Throws:
        java.lang.IllegalArgumentException - when afBD0 is null
      • Compute

        public void Compute​(float fTime,
                            int uiOrder,
                            int[] riMinIndex,
                            int[] riMaxIndex)
        evaluate basis functions and their derivatives
      • Create

        public void Create​(int iNumCtrlPoints,
                           int iDegree,
                           boolean bOpen)
        Open uniform or periodic uniform. The knot array is internally generated with equally spaced elements.
        Parameters:
        iNumCtrlPoints - number of spline control points, 2 or more.
        iDegree - polynomial degree, between 1 and iNumCtrlPoints - 1
        bOpen - true for open uniform, false for periodic uniform.
      • Create

        public void Create​(int iNumCtrlPoints,
                           int iDegree,
                           float[] afKnot)
        Open nonuniform. An internal copy is made of afKnot, so to dynamically change knots you must use the SetKnot function.
        Parameters:
        iNumCtrlPoints - number of spline control points, 2 or more.
        iDegree - polynomial degree, between 1 and iNumCtrlPoints - 1
        afKnot - The knot array must have n-d elements. The elements must be nondecreasing. Each element must be in [0,1].
      • dispose

        public void dispose()
        release resources
      • GetD0

        public float GetD0​(int i)
        Parameters:
        i - control point
        Returns:
        position
      • GetD1

        public float GetD1​(int i)
        Parameters:
        i - control point
        Returns:
        first derivative
      • GetD2

        public float GetD2​(int i)
        Parameters:
        i - control point
        Returns:
        second derivative
      • GetD3

        public float GetD3​(int i)
        Parameters:
        i - control point
        Returns:
        third derivative
      • GetDegree

        public int GetDegree()
        Returns:
        polynomial degree
      • GetKey

        public int GetKey​(float[] rfTime)
        Determine knot index i for which knot[i] <= rfTime < knot[i+1].
      • GetKnot

        public float GetKnot​(int i)
        Knot access for nonuniform splines
        Parameters:
        i - knot index
        Returns:
        knot value
      • GetKnotIndex

        public int GetKnotIndex​(float fU)
        Return the knot index i for which knot[i] <= fU < knot[i+1].
        Parameters:
        fU - Input value in the [0,1] range.
        Returns:
        Knot index in the range [0,getNumKnots()-1].
      • GetNumCtrlPoints

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

        public boolean IsOpen()
        Returns:
        Open flag
      • IsSameAs

        public boolean IsSameAs​(BSplineBasisf that)
        Return indication of whether two BSpline basis instances are the same.
        Parameters:
        that - BSplineBasisf BSpline basis instance to check for similarity.
        Returns:
        boolean True if the two BSpline basis instances represent the same set of functions.
      • IsUniform

        public boolean IsUniform()
        Returns:
        Uniform flag
      • SetKnot

        public void SetKnot​(int i,
                            float fKnot)
        Knot access for nonuniform splines
        Parameters:
        i - knot index
        fKnot - knot value
      • Allocate

        private float[][] Allocate()
        Position and derivative storage allocation.
        Returns:
        2D array of correct size
      • Initialize

        private int Initialize​(int iNumCtrlPoints,
                               int iDegree,
                               boolean bOpen)
        Common initialization.
        Parameters:
        iNumCtrlPoints - number of spline control points, 2 or more.
        iDegree - polynomial degree, between 1 and iNumCtrlPoints - 1
        bOpen - true for open uniform, false for periodic uniform.
        Returns:
        number of knots.
        See Also:
        Create(int,int,boolean)