# doc-cache created by Octave 5.1.0
# name: cache
# type: cell
# rows: 3
# columns: 15
# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
Contents


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2374
 POLYNOMIALCURVES2D Planar Polynomial Curves
 Version 1.24 07-Jun-2018 .

 POLYNOMIALCURVES2D Manipulation of planar smooth curves
   Polynomial curves are plane curves whose points are defined by a
   polynomial for each x and y coordinate.
   A polynomial curve is represented by 3 row vectors:
   * the bounds of the parametrization
   * the coefficients for the x coordinate (in increasing degree)
   * the coefficients for the y coordinate (in increasing degree)

   Example:
   C = {[0 1], [3 4], [0 1 -1]};
   represents the curve defined by:
       x(t) = 3 + 4*t;
       y(t) = t - t*t;
   for t belonging to the interval [0 1].

   As each coordinate are given by polynoms, it is possible to compute
   various parameters like curvature, normal, or the exact geodesic length
   of the curve.

   For most functions, parameters are given as three separate arguments.
   Sometimes, only the 2 parameters corresponding to the X and Y
   coefficients are required. 


 Global features
   polynomialCurveCentroid   - Compute the centroid of a polynomial curve
   polynomialCurveProjection - Projection of a point on a polynomial curve
   polynomialCurveLength     - Compute the length of a polynomial curve
   polynomialCurvePoint      - Compute point corresponding to a position
   polynomialCurvePosition   - Compute position on a curve for a given length

 Local features
   polynomialCurveDerivative - Compute derivative vector of a polynomial curve
   polynomialCurveNormal     - Compute the normal of a polynomial curve
   polynomialCurveCurvature  - Compute the local curvature of a polynomial curve
   polynomialCurveCurvatures - Compute curvatures of a polynomial revolution surface

 Fitting
   polynomialCurveFit        - Fit a polynomial curve to a series of points
   polynomialCurveSetFit     - Fit a set of polynomial curves to a segmented image

 Drawing
   drawPolynomialCurve       - Draw a polynomial curve approximation

 Utilities
   polynomialDerivate        - Derivate a polynomial
   polyfit2                  - Polynomial approximation of a curve


 -----
 Author: David Legland
 e-mail: david.legland@inra.fr
 created the  07/11/2005.
 Project homepage: http://github.com/mattools/matGeom
 http://www.pfl-cepia.inra.fr/index.php?page=geom2d
 Copyright INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 73
 POLYNOMIALCURVES2D Planar Polynomial Curves
 Version 1.24 07-Jun-2018 .



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 19
drawPolynomialCurve


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 404
DRAWPOLYNOMIALCURVE Draw a polynomial curve approximation.

   Usage
   drawPolynomialCurve(BND, XCOEFS, YCOEFS)
   drawPolynomialCurve(BND, XCOEFS, YCOEFS, NPTS)

   Example
   drawPolynomialCurve

   See also


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2011-03-21,    using Matlab 7.9.0.529 (R2009b)
 Copyright 2011 INRA - Cepia Software Platform.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 58
DRAWPOLYNOMIALCURVE Draw a polynomial curve approximation.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 8
polyfit2


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1599
POLYFIT2 Polynomial approximation of a curve.


   usage :
   P = POLYFIT2(X, Y, N) finds the coefficients of a polynomial P(X) of
   degree N that fits the data, P(X(I))~=Y(I), in a least-squares sense.

   P = POLYFIT2(Y, N) use default equal spacing between all values of Y
   array.

   P = POLYFIT2(..., COND) specify end conditions for interpolated
   polynom. COND is [M*1] array of values, M(0) is value of interpolated
   polynom for X(1), M(2) is value of first derivative at first point, and
   so on for each derivative degree of X.
   If COND is [M*2] array, first column gives conditions for first point,
   and second column gives conditions for second point.
   
   P = POLYFIT2(..., COND1, COND2) 
   where COND1 and COND2 are column arrays, specify different end
   condition for each limit of the polynom domain.
   
   Example
   % defines a basis and a function to interpolate
   N = 50;                         % 50 points
   x = linspace(0, pi, N);         % basis range from 0 to PI
   y = cos(x)+randn(1,N)*.2;       % cosine plus gaussian noise
   figure; plot(x, y, '+');        % display result
   % Fit a degree 3 polynom, imposing to pass through end points [0 1] and
   % [PI -1]:
   p1 = polyfit2(x, y, 3, [1], [-1]);
   % Fit a degree 3 polynom, imposing to pass through end points [0 1] and
   % [PI -1], and imposing first derivative equals to zero at end points:
   p2 = polyfit2(x, y, 3, [1;0], [-1;0]);
   % display the different approximations
   hold on;
   plot(x, polyval(p1, x), 'g');
   plot(x, polyval(p2, x), 'r');


   See also  :
   polyfit (matlab)




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 45
POLYFIT2 Polynomial approximation of a curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
polynomialCurveCentroid


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 920
POLYNOMIALCURVECENTROID Compute the centroid of a polynomial curve.

   C = polynomialCurveCentroid(T, XCOEF, YCOEF)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   T is a 1x2 row vector, containing the bounds of the parametrization
   variable: T = [T0 T1], with T taking all values between T0 and T1.
   C contains coordinate of the polynomila curve centroid.

   C = polynomialCurveCentroid(T, COEFS)
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   C = polynomialCurveCentroid(..., TOL)
   TOL is the tolerance fo computation (absolute).

   Example
   polynomialCurveCentroid

   See also
   polynomialCurves2d, polynomialCurveLength


 ------
 Author: David Legland
 e-mail: david.legland@gignon.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 67
POLYNOMIALCURVECENTROID Compute the centroid of a polynomial curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 24
polynomialCurveCurvature


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 804
POLYNOMIALCURVECURVATURE Compute the local curvature of a polynomial curve.

   KAPPA = polynomialCurveCurvature(T, XCOEF, YCOEF)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   KAPPA is the local curvature of the polynomial curve, computed for
   position T. If T is a vector, KAPPA has the same length as T.

   KAPPA = polynomialCurveCurvature(T, COEFS)
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   Example
   polynomialCurveCurvature

   See also
   polynomialCurves2d, polynomialCurveLength, polynomialCurveDerivative


 ------
 Author: David Legland
 e-mail: david.legland@nantes.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 75
POLYNOMIALCURVECURVATURE Compute the local curvature of a polynomial curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
polynomialCurveCurvatures


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1372
POLYNOMIALCURVECURVATURES Compute curvatures of a polynomial revolution surface.

   KAPPAS = polynomialCurveCurvatures(T, XCOEF, YCOEF)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   T is a column vector, containing the parametrization values for which
   curvatures have to be computed.
   KAPPAS is a matrix with 2 columns and as many rows as T, containing the
   2 main curvatures for each specified T.
   Curvatures are computed by assuming the curve to be rotated around the
   vertical axis (from point (0,0), in direction (1,0)).

   KAPPAS = polynomialCurveCurvatures(T, COEFS)
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   [KAPPA1 KAPPA2] = polynomialCurveCurvatures(...)
   return the 2 main curvatures in separate arrays.

   ... = polynomialCurveCurvatures(..., AXIS)
   Specify the revolution axis. By default, revolution axis is the
   vertical axis, going through point (0,0) and having direction vector
   given by (0,1). Another axis of revolution can be specified in format:
   AXIS = [x0 y0 dx dy].


   See also
   polynomialCurves2d, polynomialCurveCurvature

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 80
POLYNOMIALCURVECURVATURES Compute curvatures of a polynomial revolution surfa...



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
polynomialCurveDerivative


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 861
POLYNOMIALCURVEDERIVATIVE Compute derivative vector of a polynomial curve.

   VECT = polynomialCurveLength(T, XCOEF, YCOEF);
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   VECT is a 1x2 array containing direction of derivative of polynomial
   curve, computed for position T. If T is a vector, VECT has as many rows
   as the length of T.

   VECT = polynomialCurveLength(T, COEFS);
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   Example
   polynomialCurveDerivative

   See also
   polynomialCurves2d, polynomialCurveNormal, polynomialCurvePoint,
   polynomialCurveCurvature 


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 74
POLYNOMIALCURVEDERIVATIVE Compute derivative vector of a polynomial curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
polynomialCurveFit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 2920
POLYNOMIALCURVEFIT Fit a polynomial curve to a series of points.

   [XC YC] = polynomialCurveFit(T, XT, YT, ORDER)
   T is a Nx1 vector
   XT and YT are coordinate for each parameter value (column vectors)
   ORDER is the degree of the polynomial used for interpolation
   XC and YC are polynomial coefficients, given in ORDER+1 row vectors,
   starting from degree 0 and up to degree ORDER.

	[XC YC] = polynomialCurveFit(T, POINTS, ORDER);
   specifies coordinate of points in a Nx2 array.

   Example:
   N = 50;
   t = linspace(0, 3*pi/4, N)';
   xp = cos(t); yp = sin(t);
   [xc yc] = polynomialCurveFit(t, xp, yp, 3);
   curve = polynomialCurvePoint(t, xc, yc);
   drawCurve(curve);


	[XC YC] = polynomialCurveFit(..., T_I, COND_I);
   Impose some specific conditions. T_I is a value of the parametrization
   variable. COND_I is a cell array, with 2 columns, and as many rows as
   the derivatives specified for the given T_I. Format for COND_I is:
   COND_I = {X_I, Y_I; X_I', Y_I'; X_I", Y_I"; ...};
   with X_I and Y_I being the imposed coordinate at position T_I, X_I' and
   Y_I' being the imposed first derivatives, X_I" and Y_I" the imposed
   second derivatives, and so on...
   To specify a derivative without specifying derivative with lower
   degree, value of lower derivative can be let empty, using '[]'

   Example:
   % defines a curve (circle arc) with small perturbations
   N = 100;
   t = linspace(0, 3*pi/4, N)';
   xp = cos(t)+.1*randn(size(t)); yp = sin(t)+.1*randn(size(t));
   
   % plot the points
   figure(1); clf; hold on;
   axis([-1.2 1.2 -.2 1.2]); axis equal;
   drawPoint(xp, yp);

   % fit without knowledge on bounds
   [xc0 yc0] = polynomialCurveFit(t, xp, yp, 5);
   curve0 = polynomialCurvePoint(t, xc0, yc0);
   drawCurve(curve0);

   % fit by imposing coordinate on first point
   [xc1 yc1] = polynomialCurveFit(t, xp, yp, 5, 0, {1, 0});
   curve1 = polynomialCurvePoint(t, xc1, yc1);
   drawCurve(curve1, 'r');

   % fit by imposing coordinate (1,0) and derivative (0,1) on first point
   [xc2 yc2] = polynomialCurveFit(t, xp, yp, 5, 0, {1, 0;0 1});
   curve2 = polynomialCurvePoint(t, xc2, yc2);
   drawCurve(curve2, 'g');

   % fit by imposing several conditions on various points
   [xc3 yc3] = polynomialCurveFit(t, xp, yp, 5, ...
       0, {1, 0;0 1}, ...      % coord and first derivative of first point
       3*pi/4, {-sqrt(2)/2, sqrt(2)/2}, ...    % coord of last point
       pi/2, {[], [];-1, 0});      % derivative of point on the top of arc
   curve3 = polynomialCurvePoint(t, xc3, yc3);
   drawCurve(curve3, 'k');

   Requires the optimization Toolbox.


   Examples:
   polynomialCurveFit

   See also
   polynomialCurves2d

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-27
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 64
POLYNOMIALCURVEFIT Fit a polynomial curve to a series of points.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
polynomialCurveLength


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 864
POLYNOMIALCURVELENGTH Compute the length of a polynomial curve.

   LENGTH = polynomialCurveLength(T, XCOEF, YCOEF)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   T is a 1x2 row vector, containing the bounds of the parametrization
   variable: T = [T0 T1], with T taking all values between T0 and T1.

   LENGTH = polynomialCurveLength(T, COEFS)
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   LENGTH = polynomialCurveLength(..., TOL)
   TOL is the tolerance fo computation (absolute).

   Example
   polynomialCurveLength

   See also
   polynomialCurves2d, polynomialCurveCentroid

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
POLYNOMIALCURVELENGTH Compute the length of a polynomial curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
polynomialCurveNormal


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 781
POLYNOMIALCURVENORMAL Compute the normal of a polynomial curve.

   N = polynomialCurveNormal(T, XCOEF, YCOEF)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   T is a 1x2 row vector, containing the bounds of the parametrization
   variable: T = [T0 T1], with T taking all values between T0 and T1.
   T can also be a larger vector, in this case only bounds are kept.
   N is a 1x2 row vector, containing direction of curve normal in T.
   If T is column vector, the result is a matrix with 2 columns containing
   normal vector for each position.

   The normal is oriented such that oriented angle from derivative
   vector to normal vector equals PI/2. The normal points to the 'left'
   when travelling along the curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
POLYNOMIALCURVENORMAL Compute the normal of a polynomial curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 20
polynomialCurvePoint


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 865
POLYNOMIALCURVEPOINT Compute point corresponding to a position.

   POINT = polynomialCurvePoint(T, XCOEF, YCOEF)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   T is a either a scalar, or a column vector, containing values of the
   parametrization variable.
   POINT is a 1x2 array containing coordinate of point corresponding to
   position given by T. If T is a vector, POINT has as many rows as T.

   POINT = polynomialCurvePoint(T, COEFS)
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   Example
   polynomialCurvePoint

   See also
   polynomialCurves2d, polynomialCurveLength


 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 63
POLYNOMIALCURVEPOINT Compute point corresponding to a position.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 23
polynomialCurvePosition


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 977
POLYNOMIALCURVEPOSITION Compute position on a curve for a given length.

   POS = polynomialCurvePosition(T, XCOEF, YCOEF, L)
   XCOEF and YCOEF are row vectors of coefficients, in the form:
       [a0 a1 a2 ... an]
   T is a 1x2 row vector, containing the bounds of the parametrization
   variable: T = [T0 T1], with T taking all values between T0 and T1.
   L is the geodesic length corresponding to the searched position.
   POS is a scalar, verifying relation:
   L = polynomialCurveLength([T(1) POS], XCOEF, YCOEF);

   POS = polynomialCurvePosition(T, COEFS, L)
   COEFS is either a 2xN matrix (one row for the coefficients of each
   coordinate), or a cell array.

   POS = polynomialCurvePosition(..., TOL)
   TOL is the tolerance fo computation (absolute).

   See also
   polynomialCurves2d

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-26
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 71
POLYNOMIALCURVEPOSITION Compute position on a curve for a given length.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 25
polynomialCurveProjection


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 501
POLYNOMIALCURVEPROJECTION Projection of a point on a polynomial curve.

   T = polynomialCurveProjection([T0 T1], XCOEFS, YCOEFS, POINT); 
   Computes the position of POINT on the polynomial curve, such that 
   polynomialCurvePoint([T0 T1], XCOEFS, YCOEFS) is the same as POINT.

   See also
   polynomialCurves2d, polynomialCurvePoint

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-12-21
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 70
POLYNOMIALCURVEPROJECTION Projection of a point on a polynomial curve.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 21
polynomialCurveSetFit


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 1204
POLYNOMIALCURVESETFIT Fit a set of polynomial curves to a segmented image.

   COEFS = polynomialCurveSetFit(IMG);
   COEFS = polynomialCurveSetFit(IMG, DEG);
   Result is a cell array of matrices. Each matrix is DEG+1-by-2, and
   contains coefficients of polynomial curve for each coordinate.
   IMG is first binarised, then skeletonized. Each cure

   [COEFS LBL] = polynomialCurveSetFit(...);
   also returns an image of labels for the segmented curves. The max label
   is the number of curves, and the length of COEFS.

   Requires the toolboxes:
   - Optimization
   - Image Processing

   Example
     % Fit a set of curves to a binary skeleton
     img = imread('circles.png');
     % compute skeleton, and ensure one-pixel thickness
     skel = bwmorph(img, 'skel', 'Inf');
     skel = bwmorph(skel, 'shrink');
     figure; imshow(skel==0)
     coeffs = polynomialCurveSetFit(skel, 2);
     % Display segmented image with curves
     figure; imshow(~img); hold on;
     for i = 1:length(coeffs)
         hc = drawPolynomialCurve([0 1], coeffs{i});
         set(hc, 'linewidth', 2, 'color', 'g');
     end

   See also
   polynomialCurves2d, polynomialCurveFit




# name: <cell-element>
# type: sq_string
# elements: 1
# length: 74
POLYNOMIALCURVESETFIT Fit a set of polynomial curves to a segmented image.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 18
polynomialDerivate


# name: <cell-element>
# type: sq_string
# elements: 1
# length: 515
POLYNOMIALDERIVATE Derivate a polynomial.

   DERIV = polynomialDERIVATE(POLY)
   POLY is a row vector of [n+1] coefficients, in the form:
       [a0 a1 a2 ... an]
   DERIV has the same format, with length n:
       [a1 a2*2 ... an*n]


   Example
   T = polynomialDerivate([2 3 4])
   returns:
   T = [3 8]

   See also
   polynomialCurves2d

 ------
 Author: David Legland
 e-mail: david.legland@grignon.inra.fr
 Created: 2007-02-23
 Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.



# name: <cell-element>
# type: sq_string
# elements: 1
# length: 41
POLYNOMIALDERIVATE Derivate a polynomial.





