
<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <!--
This HTML was auto-generated from MATLAB code.
To make changes, update the MATLAB code and republish this document.
      --><title>demoParabolaCurvature</title><meta name="generator" content="MATLAB 8.6"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2016-08-31"><meta name="DC.source" content="demoParabolaCurvature.m"><style type="text/css">
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}

html { min-height:100%; margin-bottom:1px; }
html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; }
html body td { vertical-align:top; text-align:left; }

h1 { padding:0px; margin:0px 0px 25px; font-family:Arial, Helvetica, sans-serif; font-size:1.5em; color:#d55000; line-height:100%; font-weight:normal; }
h2 { padding:0px; margin:0px 0px 8px; font-family:Arial, Helvetica, sans-serif; font-size:1.2em; color:#000; font-weight:bold; line-height:140%; border-bottom:1px solid #d6d4d4; display:block; }
h3 { padding:0px; margin:0px 0px 5px; font-family:Arial, Helvetica, sans-serif; font-size:1.1em; color:#000; font-weight:bold; line-height:140%; }

a { color:#005fce; text-decoration:none; }
a:hover { color:#005fce; text-decoration:underline; }
a:visited { color:#004aa0; text-decoration:none; }

p { padding:0px; margin:0px 0px 20px; }
img { padding:0px; margin:0px 0px 20px; border:none; }
p img, pre img, tt img, li img, h1 img, h2 img { margin-bottom:0px; } 

ul { padding:0px; margin:0px 0px 20px 23px; list-style:square; }
ul li { padding:0px; margin:0px 0px 7px 0px; }
ul li ul { padding:5px 0px 0px; margin:0px 0px 7px 23px; }
ul li ol li { list-style:decimal; }
ol { padding:0px; margin:0px 0px 20px 0px; list-style:decimal; }
ol li { padding:0px; margin:0px 0px 7px 23px; list-style-type:decimal; }
ol li ol { padding:5px 0px 0px; margin:0px 0px 7px 0px; }
ol li ol li { list-style-type:lower-alpha; }
ol li ul { padding-top:7px; }
ol li ul li { list-style:square; }

.content { font-size:1.2em; line-height:140%; padding: 20px; }

pre, code { font-size:12px; }
tt { font-size: 1.2em; }
pre { margin:0px 0px 20px; }
pre.codeinput { padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }
pre.codeoutput { padding:10px 11px; margin:0px 0px 20px; color:#4c4c4c; }
pre.error { color:red; }

@media print { pre.codeinput, pre.codeoutput { word-wrap:break-word; width:100%; } }

span.keyword { color:#0000FF }
span.comment { color:#228B22 }
span.string { color:#A020F0 }
span.untermstring { color:#B20000 }
span.syscmd { color:#B28C00 }

.footer { width:auto; padding:10px 0px; margin:25px 0px 0px; border-top:1px dotted #878787; font-size:0.8em; line-height:140%; font-style:italic; color:#878787; text-align:left; float:none; }
.footer p { margin:0px; }
.footer a { color:#878787; }
.footer a:hover { color:#878787; text-decoration:underline; }
.footer a:visited { color:#878787; }

table th { padding:7px 5px; text-align:left; vertical-align:middle; border: 1px solid #d6d4d4; font-weight:bold; }
table td { padding:7px 5px; text-align:left; vertical-align:top; border:1px solid #d6d4d4; }





  </style></head><body><div class="content"><h2>Contents</h2><div><ul><li><a href="#2">Parabola definition</a></li><li><a href="#3">Compute curvature for a specific position</a></li></ul></div><pre class="codeinput"><span class="comment">%DEMOPARABOLACURVATURE  One-line description here, please.</span>
<span class="comment">%   output = demoParabolaCurvature(input)</span>
<span class="comment">%</span>
<span class="comment">%   Example</span>
<span class="comment">%   demoParabolaCurvature</span>
<span class="comment">%</span>
<span class="comment">%   See also</span>
<span class="comment">%</span>

<span class="comment">% ------</span>
<span class="comment">% Author: David Legland</span>
<span class="comment">% e-mail: david.legland@nantes.inra.fr</span>
<span class="comment">% Created: 2007-02-26</span>
<span class="comment">% Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.</span>
</pre><h2>Parabola definition<a name="2"></a></h2><pre class="codeinput"><span class="comment">% parameters of polynomial curve (here, a parabola)</span>
c1 = [0 1];
c2 = [0 0 .5];

<span class="comment">% parametrization for a parabola arc</span>
t = linspace(-1, 3, 100)';

<span class="comment">% approximation of the curve</span>
curve = polynomialCurvePoint(t, c1, c2);

<span class="comment">% prepare plot</span>
figure(1); clf;
hold <span class="string">on</span>;

<span class="comment">% draw curve</span>
drawPolyline(curve, <span class="string">'linewidth'</span>, 2);

<span class="comment">% format axis</span>
axis <span class="string">equal</span>;
axis([-2 3 0 5]);
</pre><img vspace="5" hspace="5" src="demoParabolaCurvature_01.png" alt=""> <h2>Compute curvature for a specific position<a name="3"></a></h2><pre class="codeinput"><span class="comment">% the position</span>
pos = .5;

<span class="comment">% point, derivative and  curvature at chosen point</span>
point = polynomialCurvePoint(pos, c1, c2);
deriv = polynomialCurveDerivative(pos, c1, c2);
kappa = polynomialCurveCurvature(pos, c1, c2);

<span class="comment">% radius is the inverse of the curvature</span>
radius = 1./kappa;

<span class="comment">% tangent and normal lines</span>
tangent = [point deriv];
normal = orthogonalLine(tangent, point);

<span class="comment">% osculating circle</span>
center = pointOnLine(normal, radius);
circle = [center radius];

<span class="comment">% display tangent line, normal, and osculating circle</span>
drawPoint(point, <span class="string">'color'</span>, <span class="string">'k'</span>);
drawLine(tangent, <span class="string">'color'</span>, <span class="string">'k'</span>);
drawLine(normal, <span class="string">'color'</span>, <span class="string">'k'</span>);
drawCircle(circle, <span class="string">'color'</span>, <span class="string">'k'</span>);
</pre><img vspace="5" hspace="5" src="demoParabolaCurvature_02.png" alt=""> <p class="footer"><br><a href="http://www.mathworks.com/products/matlab/">Published with MATLAB&reg; R2015b</a><br></p></div><!--
##### SOURCE BEGIN #####
%DEMOPARABOLACURVATURE  One-line description here, please.
%   output = demoParabolaCurvature(input)
%
%   Example
%   demoParabolaCurvature
%
%   See also
%

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


%% Parabola definition

% parameters of polynomial curve (here, a parabola)
c1 = [0 1];
c2 = [0 0 .5];

% parametrization for a parabola arc
t = linspace(-1, 3, 100)';

% approximation of the curve
curve = polynomialCurvePoint(t, c1, c2);

% prepare plot
figure(1); clf;
hold on;

% draw curve
drawPolyline(curve, 'linewidth', 2);

% format axis
axis equal;
axis([-2 3 0 5]);


%% Compute curvature for a specific position

% the position
pos = .5;

% point, derivative and  curvature at chosen point
point = polynomialCurvePoint(pos, c1, c2);
deriv = polynomialCurveDerivative(pos, c1, c2);
kappa = polynomialCurveCurvature(pos, c1, c2);

% radius is the inverse of the curvature
radius = 1./kappa;

% tangent and normal lines
tangent = [point deriv];
normal = orthogonalLine(tangent, point);

% osculating circle
center = pointOnLine(normal, radius);
circle = [center radius];

% display tangent line, normal, and osculating circle
drawPoint(point, 'color', 'k');
drawLine(tangent, 'color', 'k');
drawLine(normal, 'color', 'k');
drawCircle(circle, 'color', 'k');

##### SOURCE END #####
--></body></html>