http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492
MATLAB Central Newsreader  Plotting circle tangent to a curve in 3d
Feed for thread: Plotting circle tangent to a curve in 3d
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 01 Mar 2012 14:10:17 +0000
Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#868499
Edward Tan
Hi,<br>
I have a question which requires advice from the community. I have a curve in 3D plot and I want to plot circles with its center coincide with the points on the curve. In additional, i would like the circles oriented such that its radius and theta plane is normal to the tangent of the curve. Can someone help advise on this? Thank you very much for your time.<br>
<br>
Thanks<br>
Edward

Thu, 01 Mar 2012 20:38:12 +0000
Re: Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#868533
Roger Stafford
"Edward Tan" <octrs@hotmail.com> wrote in message <jio009$84g$1@newscl01ah.mathworks.com>...<br>
> Hi,<br>
> I have a question which requires advice from the community. I have a curve in 3D plot and I want to plot circles with its center coincide with the points on the curve. In additional, i would like the circles oriented such that its radius and theta plane is normal to the tangent of the curve. Can someone help advise on this? Thank you very much for your time.<br>
> <br>
> Thanks<br>
> Edward<br>
       <br>
Suppose that P0 is the point about which a circle is to be drawn with radius R and with the plane of the circle orthogonal to the tangent direction of the curve at P0. Let P1 be the previous point on the curve to P0 and P2 the following point. Let all three points be represented by 1 by 3 row vectors of cartesian coordinates. Then do this:<br>
<br>
P10 = P1P0;<br>
P20 = P2P0;<br>
N = dot(P10,P10)*P20dot(P20,P20)*P10; % < Approx. tangent direction<br>
T = null(N).'; % Get two orthogonal unit vectors which are orthog. to N<br>
theta = linspace(0,2*pi).';<br>
V = bsxfun(@plus,R*(cos(theta)*T(1,:)+sin(theta)*T(2,:)),P0);<br>
plot3(V(:,1),V(:,2),V(:,3))<br>
<br>
The vector N approximates the curve tangent direction at P0 in terms of the two neighboring points P1 and P2. As theta advances from 0 to 2*pi, the array V traces out the desired circle with P0 at the center and plane orthogonal to N.<br>
<br>
Roger Stafford

Thu, 01 Mar 2012 22:18:12 +0000
Re: Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#868553
Edward Tan
Hi Roger,<br>
Thank you very much for your help. It works and thank you for the detail explanation.<br>
<br>
Have a nice day<br>
Edward<br>
<br>
"Roger Stafford" wrote in message <jiomnj$t63$1@newscl01ah.mathworks.com>...<br>
> "Edward Tan" <octrs@hotmail.com> wrote in message <jio009$84g$1@newscl01ah.mathworks.com>...<br>
> > Hi,<br>
> > I have a question which requires advice from the community. I have a curve in 3D plot and I want to plot circles with its center coincide with the points on the curve. In additional, i would like the circles oriented such that its radius and theta plane is normal to the tangent of the curve. Can someone help advise on this? Thank you very much for your time.<br>
> > <br>
> > Thanks<br>
> > Edward<br>
>        <br>
> Suppose that P0 is the point about which a circle is to be drawn with radius R and with the plane of the circle orthogonal to the tangent direction of the curve at P0. Let P1 be the previous point on the curve to P0 and P2 the following point. Let all three points be represented by 1 by 3 row vectors of cartesian coordinates. Then do this:<br>
> <br>
> P10 = P1P0;<br>
> P20 = P2P0;<br>
> N = dot(P10,P10)*P20dot(P20,P20)*P10; % < Approx. tangent direction<br>
> T = null(N).'; % Get two orthogonal unit vectors which are orthog. to N<br>
> theta = linspace(0,2*pi).';<br>
> V = bsxfun(@plus,R*(cos(theta)*T(1,:)+sin(theta)*T(2,:)),P0);<br>
> plot3(V(:,1),V(:,2),V(:,3))<br>
> <br>
> The vector N approximates the curve tangent direction at P0 in terms of the two neighboring points P1 and P2. As theta advances from 0 to 2*pi, the array V traces out the desired circle with P0 at the center and plane orthogonal to N.<br>
> <br>
> Roger Stafford

Fri, 02 Mar 2012 01:41:12 +0000
Re: Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#868562
Roger Stafford
"Edward Tan" <octrs@hotmail.com> wrote in message <jiosj4$k5c$1@newscl01ah.mathworks.com>...<br>
> Thank you very much for your help. It works and thank you for the detail explanation.<br>
> "Roger Stafford" wrote in message <jiomnj$t63$1@newscl01ah.mathworks.com>...<br>
> > N = dot(P10,P10)*P20dot(P20,P20)*P10; % < Approx. tangent direction<br>
        <br>
I should have explained what sort of approximation to the curve tangent direction the vector N is. It points along the line tangent to the circle at P0 which passes through the three points P1, P0, and P2. In case these are colinear and no circle is possible it is just the direction along their common line. It is assumed none of the three points coincide.<br>
<br>
Roger Stafford

Thu, 15 Mar 2012 19:40:34 +0000
Re: Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#870131
Edward Tan
"Roger Stafford" wrote in message <jip8fo$p8k$1@newscl01ah.mathworks.com>...<br>
> "Edward Tan" <octrs@hotmail.com> wrote in message <jiosj4$k5c$1@newscl01ah.mathworks.com>...<br>
> > Thank you very much for your help. It works and thank you for the detail explanation.<br>
> > "Roger Stafford" wrote in message <jiomnj$t63$1@newscl01ah.mathworks.com>...<br>
> > > N = dot(P10,P10)*P20dot(P20,P20)*P10; % < Approx. tangent direction<br>
>         <br>
> I should have explained what sort of approximation to the curve tangent direction the vector N is. It points along the line tangent to the circle at P0 which passes through the three points P1, P0, and P2. In case these are colinear and no circle is possible it is just the direction along their common line. It is assumed none of the three points coincide.<br>
> <br>
> Roger Stafford<br>
<br>
Thanks Roger for the explanation. I have an another question to consult if you don't mind. I have a 2D plot of a contour and want to orientate it in the same way as what I previous wanted, normal to the tangent of the curve. Can I use the similar approached which you have described in your previous reply?<br>
<br>
Thanks and have a nice day<br>
Edward<br>

Thu, 15 Mar 2012 23:38:21 +0000
Re: Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#870146
Roger Stafford
"Edward Tan" <octrs@hotmail.com> wrote in message <jjtgji$75v$1@newscl01ah.mathworks.com>...<br>
> Thanks Roger for the explanation. I have an another question to consult if you don't mind. I have a 2D plot of a contour and want to orientate it in the same way as what I previous wanted, normal to the tangent of the curve. Can I use the similar approached which you have described in your previous reply?<br>
          <br>
You can find the normal vector N the same way. However you need to decide on two additional parameters that determine the orientation of the transformed contour curve: 1) the point in the plane of that new contour that is to coincide with the tangent point on the other curve, and 2) the rotational orientation of the contour within its new plane. In the case of the circle you located its center on the curve and a circle is invariant with respect to rotation about that center so it didn't matter which vectors in T were selected by 'null' as long as they were orthogonal to N. For an arbitrary contour curve it will make a difference as to how it is rotated unless it too is a circle.<br>
<br>
Roger Stafford

Fri, 16 Mar 2012 17:08:11 +0000
Re: Plotting circle tangent to a curve in 3d
http://www.mathworks.com/matlabcentral/newsreader/view_thread/317492#870249
Edward Tan
"Roger Stafford" wrote in message <jjtuhd$kfv$1@newscl01ah.mathworks.com>...<br>
> "Edward Tan" <octrs@hotmail.com> wrote in message <jjtgji$75v$1@newscl01ah.mathworks.com>...<br>
> > Thanks Roger for the explanation. I have an another question to consult if you don't mind. I have a 2D plot of a contour and want to orientate it in the same way as what I previous wanted, normal to the tangent of the curve. Can I use the similar approached which you have described in your previous reply?<br>
>           <br>
> You can find the normal vector N the same way. However you need to decide on two additional parameters that determine the orientation of the transformed contour curve: 1) the point in the plane of that new contour that is to coincide with the tangent point on the other curve, and 2) the rotational orientation of the contour within its new plane. In the case of the circle you located its center on the curve and a circle is invariant with respect to rotation about that center so it didn't matter which vectors in T were selected by 'null' as long as they were orthogonal to N. For an arbitrary contour curve it will make a difference as to how it is rotated unless it too is a circle.<br>
> <br>
> Roger Stafford<br>
<br>
Thanks for the explanation. It seems that it is alot more complicated than what I thought as the contour is not a circle. I have assigned a point in the plane, for each contour I would like to plot, to coincide with the tangent point. So for each contour, I have the X, Y, Z values, which would place the contour in the 3D space. Only problem is that I do not know where to start in getting the rotational orientation right. Will you be able to guide me on that? Thank you for your time.<br>
<br>
Edward