From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Moving a straight line segment along the curve (Animation)
Date: Sat, 2 Apr 2011 00:53:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <in5s1h$gdl$>
References: <in5ad5$6np$> <in5ei8$igt$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1301705585 16821 (2 Apr 2011 00:53:05 GMT)
NNTP-Posting-Date: Sat, 2 Apr 2011 00:53:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:719631

"Roger Stafford" wrote in message <in5ei8$igt$>...
>   I presume when you say "rotate the line" you mean that you want the line segment to be tangent to the interpolated curve.  You could accomplish that by using the 'ppform', which is the output of 'cscvn', to directly calculate the derivative of the cubic polynomial within whatever cubic section of the spline-fit the point of tangency is located.  That establishes the slope desired for the line segment.  In your animation this would of course have to be repeated for each point of tangency along the curve.
>   Yesterday in a different thread you inquired about curvature in connection with the use of 'cscvn'.  You can also use its 'ppform' output to directly calculate the curvature of cubic sections at any desired points within them.  The formula is well known in calculus: curvature is equal to the second derivative divided by the three-halves power of the quantity: one plus the square of the first derivative.  Cubic polynomials have very well-defined second, as well as first, derivatives.
> Roger Stafford
- - - - - - - - - -
  The curvature formula I mentioned needs a clarification.  In the spline representation given by 'cscvn' using the 'ppform' format, the coordinates are given as cubic polynomial sections of a common parameter, namely an approximate arc length s.  For that reason the curvature formula that applies should be the corresponding parametric form:

 K = ((dxds)*(d2yds2)-(dyds)*(d2xds2))/((dxds)^2+(dyds)^2)^(3/2)

where dxds and dyds designate the first derivatives with respect to s and d2xds2 and d2yds2 are the second derivatives.

  The tangent line segment should have direction cosines proportional to (dxds) and (dyds).

Roger Stafford