CRPWPC   

Equivalent PK functions: PK_BCURVE_create_piecewise

CRPWPC ( dim, order, nsegs, coeffs, basis, bc, ifail )
======================================================

  Create B-curve from piecewise data

Receives:
  KI_int_dimension         *dim            --- dimension of defining vectors
  KI_int_order             *order          --- order of curve
  KI_int_nitems            *nsegs          --- number of segments in curve
  KI_dbl_coefficients       coeffs[dim * order * nsegs]
                                           --- vectors defining the curve
  KI_cod_slba              *basis          --- representation method

Returns:
  KI_tag_b_curve           *bc             --- B-curve
  KI_cod_error             *ifail          --- failure indicator

Specific errors:
  KI_discontinuous_curve    adjacent segments must meet
  KI_weight_le_0            weights must be greater than zero
  KI_bad_order              'order' must be four for Hermite basis

Description:
  This function creates a B-curve from piecewise data. The following
  methods of representing the data are available:

   o Bezier                   ('basis' = SLBABZ)
   o Polynomial               ('basis' = SLBAPY)
   o Hermite (cubic only)     ('basis' = SLBAHE)
   o Taylor series            ('basis' = SLBATA)

  Dimension of coefficient vectors 'dim':
  . For rational curves 'dim'=4.
  . For non-rational curves 'dim'=3.

  Order of each segment of the curve 'order':
  . The order of the curve = degree + 1.
  . The minimum order is 2.
  . If the Hermite basis is used ('basis' = SLBAHE) then the curve has
    to be cubic ('order' = 4).

  Number of segments in the curve 'nseg':
  . There must be at least one segment ('nseg' >= 1).
  . Adjacent segments must meet.

  Coefficient data 'coeffs':
  . Contains 'order'*'nseg' vectors of dimension 'dim'. If 'dim'=3, then the
    vectors are 3-D vectors giving the x, y and z components. If 'dim'=4,
    then each vector has a weight (w) associated with it, and x, y, z and w
    components are supplied for each vector. The weights supplied must be
    greater than zero.
  . The coefficients are supplied in order, segment by segment.
  . The interpretation of the coefficients depends on the representation method
    chosen; this is determined by the value of the argument 'basis'.

  Representation method 'basis':
    The expressions for each segment of the B-curve P(t) in the various
    representations are given below. For generality, the rational form is given.
    The simplification to the non-rational form can be obtained by setting both
    the weights and the denominator equal to 1.0.

  . Bezier vertices SLBABZ:

    The equation of a rational Bezier curve segment is:

                     n                    n
                     --                /  --
          P(t)   =   >   b (t) w  V   /   >  b (t) w
                     --   i     i  i /    --  i     i
                    i=0                   i=0

          where n     = 'order'-1
                V     = Bezier vertex
                 i
                w     = weight for V
                 i                  i
                b (t) = Bezier coefficient, defined by:
                 i
                      n!       i       n-i
          b (t) = --------  * t * (1-t)
           i      i! (n-i)!

    The Bezier vertices are supplied V ,w ,...,V ,w   for the rational form, or
                                      0  0      n  n
    V ,...,V  for the non-rational form.
     0      n

  . Polynomial coefficients SLBAPY:

    The curve equation is given by a rational polynomial of order 'order':

                     n                 n
                     --         i   /  --     i
          P(t)   =   >   w  A  t   /   >  w  t
                     --   i  i    /    --  i
                    i=0               i=0

          where n = 'order'-1
                A = polynomial coefficient
                 i
                w = weight for A
                 i              i

    The polynomial coefficients are supplied starting with the constant
    term and ending with the term of highest degree.

  . Hermite coefficients SLBAHE:

    This method can only be used for cubics. The equation of the curve is:

                 f0(t) w0 P0 + g0(t) w1 P1 + f1(t) d0 D0 + g1(t) d1 D1
          P(t) = -----------------------------------------------------
                     f0(t) w0  + g0(t) w1 + f1(t) d0 + g1(t) d1

                                2    3                      2     3
          where f0(t)  =  1 - 3t + 2t          g0(t)  =  3t  - 2t

                                2    3                       2    3
                f1(t)  =  t - 2t  + t           g1(t)  =  - t  + t

                P0, P1 = start and end points of segment
                D0, D1 = derivatives at start and end
                w0, w1 = weights at end points
                d0, d1 = derivatives of weights at start and end

  The coefficients are supplied as P0,w0,P1,w1,D0,d0,D1,d1 for the rational
  form, or P0,P1,D0,D1 for the non-rational form.

  . Taylor series SLBATA:

    This method stores the derivatives evaluated at the point start of each
    segment, allowing the curve to be reconstructed as a Taylor series:

                     n
                     --    (i) (i)  i
                     >    w   P    t   /  i!
                     --
                     i=0
          P(t)   =   -----------------------
                      n
                      --     (i)  i
                      >     w    t  / i!
                      --
                     i=0

          where n = 'order'-1
                 (i)
                P    = i'th derivative at t = 0
                 (i)
                w    = i'th derivative of weight at t = 0

    The point is supplied first, followed by the 1st derivative and ending
    with the derivative of order 'order'-1.