<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172917</link>
    <title>MATLAB Central Newsreader - How to compute the Normal of a curve at some points?</title>
    <description>Feed for thread: How to compute the Normal of a curve at some points?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 20 Jul 2008 15:24:27 -0400</pubDate>
      <title>How to compute the Normal of a curve at some points?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172917#444192</link>
      <author>Eric</author>
      <description>A closed curve consist of a series of points. so how can I get the&lt;br&gt;
Normal of each point in this curve? Thanks very much!&lt;br&gt;
&lt;br&gt;
I got this curve by contourc.</description>
    </item>
    <item>
      <pubDate>Sun, 20 Jul 2008 20:37:01 -0400</pubDate>
      <title>Re: How to compute the Normal of a curve at some points?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172917#444214</link>
      <author>Roger Stafford</author>
      <description>Eric &amp;lt;Yonli.Zhan@gmail.com&amp;gt; wrote in message &amp;lt;077c6bd3-bc98-4e79-&lt;br&gt;
bde3-ca3bb58daad1@a3g2000prm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; A closed curve consist of a series of points. so how can I get the&lt;br&gt;
&amp;gt; Normal of each point in this curve? Thanks very much!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I got this curve by contourc.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Assuming the points in your curve are reasonably close together, you can &lt;br&gt;
approximate the arc length in terms of chord lengths between successive &lt;br&gt;
points, and then use quadratic approximation over point triplets for the &lt;br&gt;
derivatives of x and y with respect to the arc length at the middle points.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Let P1 = (x1,y1), P2 = (x2,y2), and P3 = (x3,y3) be any three successive &lt;br&gt;
points in your curve.  Then&lt;br&gt;
&lt;br&gt;
&amp;nbsp;s12 = sqrt((x2-x1)^2+(y2-y1)^2) and&lt;br&gt;
&amp;nbsp;s23 = sqrt((x3-x2)^2+(y3-y2)^2)&lt;br&gt;
&lt;br&gt;
are two successive chord lengths.  If you define quadratics in arc length, s by&lt;br&gt;
&lt;br&gt;
&amp;nbsp;x = ax*s^2+bx*s+cx&lt;br&gt;
&amp;nbsp;y = ay*s^2+by*s+cy &lt;br&gt;
&lt;br&gt;
which run through the three points, it can be shown that the derivatives dx/&lt;br&gt;
ds and dy/ds at the middle point, P2, will be given by&lt;br&gt;
&lt;br&gt;
&amp;nbsp;dxds = (s2^2*(x2-x1)+s1^2*(x3-x2))/(s1*s2*(s1+s2))&lt;br&gt;
&amp;nbsp;dyds = (s2^2*(y2-y1)+s1^2*(y3-y2))/(s1*s2*(s1+s2))&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;These should be good approximations for the components of a vector &lt;br&gt;
tangent at the middle point.  Hence the normal there will have a slope of &lt;br&gt;
approximately&lt;br&gt;
&lt;br&gt;
&amp;nbsp;-dxds/dyds&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Doing this for every triplet along the curve will give you the normal direction &lt;br&gt;
at each middle point.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;Does this give you enough to work through the problem?&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Thu, 16 Oct 2008 20:52:01 -0400</pubDate>
      <title>Re: How to compute the Normal of a curve at some points?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172917#605784</link>
      <author>Karl </author>
      <description>Thanks! This is very helpful. Alas, in trying to follow your derivation, I found the dreaded words: &quot;It can be shown that...&quot;.  Can you point me to a reference where the derivation is spelled out step by step?</description>
    </item>
    <item>
      <pubDate>Fri, 17 Oct 2008 06:11:06 -0400</pubDate>
      <title>Re: How to compute the Normal of a curve at some points?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/172917#605826</link>
      <author>Roger Stafford</author>
      <description>&quot;Karl &quot; &amp;lt;kNsOtSaPhAlM@stanford.edu&amp;gt; wrote in message &amp;lt;gd89hh$rhs$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Thanks! This is very helpful. Alas, in trying to follow your derivation, I found the dreaded words: &quot;It can be shown that...&quot;.  Can you point me to a reference where the derivation is spelled out step by step?&lt;br&gt;
-------&lt;br&gt;
&amp;nbsp;&amp;nbsp;First of all, let me apologize for the confusion of notation in that 7/20/08 article.  In the formulas for dx/ds and dy/ds where I used s1 and s2, I meant to use s12 and s23, respectively, as defined by the two previous square root formulas.  I must have been in too much of a hurry at the time.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;With s denoting the (approximate) arc length along the curve, we can call s1, s2, and s3 the (ascending) values of s at the points P1, P2, and P3.  We would then have s12 = s2-s1 and s23 = s3-s2.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;To express x as a quadratic function of s which assumes the values x1, x2, and x3 at the arc length values s1, s2, and s3, we can use the Lagrange interpolation formula&lt;br&gt;
&lt;br&gt;
&amp;nbsp;x = x1*(s-s2)*(s-s3)/(s1-s2)/(s1-s3) + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x2*(s-s1)*(s-s3)/(s2-s1)/(s2-s3) + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x3*(s-s1)*(s-s2)/(s3-s1)/(s3-s2)&lt;br&gt;
&lt;br&gt;
If we take the derivative of this x with respect to s and set s equal to s2 to get the derivative at the middle point P2, we get (after a little manipulation):&lt;br&gt;
&lt;br&gt;
&amp;nbsp;dx/ds (at s equal to s2) =&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-x1*(s3-s2)/(s2-s1)/(s3-s1) ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-x2*(2*s2-s1-s3)/(s2-s1/(s3-s2) ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;+x3*(s2-s1)/(s3-s1)/(s3-s2)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= ((x2-x1)*(s3-s2)^2+(x3-x2)*(s2-s1)^2) / ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;((s2-s1)*(s3-s2)*(s3-s1))&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;= ((x2-x1)*s23^2+(x3-x2)*s12^2) / ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(s12*s23*(s12+s23))&lt;br&gt;
&lt;br&gt;
This last is the expression I derived earlier (with s12 and s23 replacing the former confusing s1 and s2.)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;The derivation of dy/ds with y1, y2, and y3 replacing x1, x2, and x3 is done the same way.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>

