view +draw/prompt_bezier.m @ 87:0a29a60e0b21

In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
author Martin Almquist <martin.almquist@it.uu.se>
date Sun, 29 Nov 2015 22:23:09 +0100
parents 48b6fb693025
children 875386d0b2ff
line wrap: on
line source

function [C,h] = prompt_bezier(s,varargin)
    default_arg('s',[])
    if ~isempty(s)
        fprintf(s,varargin{:});
    end

    fprintf('# Draw bezier curve\n')
    a = draw.prompt_point('Enter starting point\n');
    p = draw.point(a);
    p.Color = Color.green;
    p.MarkerSize = 24;
    b = draw.prompt_point('Enter stopping point\n');
    p = draw.point(b);
    p.Color = Color.red;
    p.MarkerSize = 24;
    c1 = draw.prompt_point('Enter control point 1\n');
    p = draw.point(c1);
    p.Color = Color.yellow;
    p.MarkerSize = 16;
    c2 = draw.prompt_point('Enter control point 2\n');
    p = draw.point(c2);
    p.Color = Color.yellow;
    p.MarkerSize = 16;

    C = grid.Curve.bezier(a,c1,c2,b);
    fprintf('C = grid.Curve.bezier([%.3g; %.3g],[%.3g; %.3g],[%.3g; %.3g],[%.3g; %.3g]);\n',a,c1,c2,b)
    h = C.plot();
    uistack(h,'bottom');

end