http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605
MATLAB Central Newsreader  a circle in 3D
Feed for thread: a circle in 3D
enus
©19942017 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://nl.mathworks.com/images/membrane_icon.gif

Mon, 18 Jul 2011 19:47:08 +0000
a circle in 3D
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605#845829
Marie
Hi, I'm required to graph the osculating circle of point at a 3D curve, but how do I do that if I have the radius of the circle and the center point?<br>
<br>
What I have so far:<br>
<br>
THETA = linspace(0,2*pi,100);<br>
RHO = ones(1,100)*radius;<br>
[X,Y] = pol2cart(THETA,RHO);<br>
X = X+center(1);<br>
Y = Y+center(2);<br>
Z = center(3)*ones(1,length(X));<br>
H = plot3(X,Y,Z,'r');<br>
<br>
But all this does this graph the circle in XY with height Z; it doesn't make the circle lie on the osculating plane (in other words, the circle doesn't lie on tangent line at point r(t)).<br>
<br>
I guess what I'm wondering is if there's a similar function to pol2cart, except with Z added in?<br>
<br>
Thanks so much.

Mon, 18 Jul 2011 20:49:09 +0000
Re: a circle in 3D
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605#845840
Roger Stafford
"Marie " <mrvns3@gmail.com> wrote in message <j022js$mr5$1@newscl01ah.mathworks.com>...<br>
> Hi, I'm required to graph the osculating circle of point at a 3D curve, but how do I do that if I have the radius of the circle and the center point?<br>
> .......<br>
          <br>
You need more than just a radius and center to determine a threedimensional circle. You need a vector normal to the plane of the osculating circle also. If you look up in your calculus book, there is a method based on the first and second derivatives of the given space curve at the point of tangency for determining this normal vector.<br>
<br>
I will give a method in terms of vector analysis and you can translate that into matlab code. Suppose u is a unit vector pointing from the center toward the point of tangency and v a unit vector normal to the osculating plane. Then w = cross(u,v) will be a unit vector orthogonal to u and v. Let c be the center point. Then all points P along the circle can be generated by:<br>
<br>
P = c + r*(sin(theta)*u + cos(theta)*w);<br>
<br>
for an angle theta which ranges from 0 to 2*pi and r the circle's radius.<br>
<br>
Does that help you?<br>
<br>
(Note: You also need those same derivatives mentioned above for determining the radius and center.)<br>
<br>
Roger Stafford

Mon, 18 Jul 2011 22:44:09 +0000
Re: a circle in 3D
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605#845854
Roger Stafford
"Roger Stafford" wrote in message <j02685$4hm$1@newscl01ah.mathworks.com>...<br>
> .......<br>
> I will give a method in terms of vector analysis and you can translate that into matlab code. Suppose u is a unit vector pointing from the center toward the point of tangency and v a unit vector normal to the osculating plane. Then w = cross(u,v) will be a unit vector orthogonal to u and v. Let c be the center point. Then all points P along the circle can be generated by:<br>
> <br>
> P = c + r*(sin(theta)*u + cos(theta)*w);<br>
> <br>
> for an angle theta which ranges from 0 to 2*pi and r the circle's radius.<br>
> .......<br>
        <br>
There is an easier way of thinking about your problem than the one I gave earlier. The first derivatives of the parametric equations that determine your space curve after being normalized to a unit vector tangent to the curve at the given point, give you the vector w I referred to. The vector u is determined from the second derivatives in the process of determining the location of the center of curvature and the radius. It is unnecessary to deal with the normal, v, to the osculating plane for generating the circle.<br>
<br>
Roger Stafford

Tue, 19 Jul 2011 03:01:12 +0000
Re: a circle in 3D
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605#845864
Marie
"Roger Stafford" wrote in message <j02cvp$lq9$1@newscl01ah.mathworks.com>...<br>
> "Roger Stafford" wrote in message <j02685$4hm$1@newscl01ah.mathworks.com>...<br>
> > .......<br>
> > I will give a method in terms of vector analysis and you can translate that into matlab code. Suppose u is a unit vector pointing from the center toward the point of tangency and v a unit vector normal to the osculating plane. Then w = cross(u,v) will be a unit vector orthogonal to u and v. Let c be the center point. Then all points P along the circle can be generated by:<br>
> > <br>
> > P = c + r*(sin(theta)*u + cos(theta)*w);<br>
> > <br>
> > for an angle theta which ranges from 0 to 2*pi and r the circle's radius.<br>
> > .......<br>
>         <br>
> There is an easier way of thinking about your problem than the one I gave earlier. The first derivatives of the parametric equations that determine your space curve after being normalized to a unit vector tangent to the curve at the given point, give you the vector w I referred to. The vector u is determined from the second derivatives in the process of determining the location of the center of curvature and the radius. It is unnecessary to deal with the normal, v, to the osculating plane for generating the circle.<br>
> <br>
> Roger Stafford<br>
<br>
Thank you so much for your reply.<br>
<br>
Yes, I have the unit normal vector, unit tangent vector, the radius (found by 1/curvature), and the center point. <br>
<br>
So you're saying that "u" is on the normal vector, "v" is the tangent vector, and "w" (being cross(u,v)) is the binormal, and with c= center point and r = radius, I need to graph P = c + r*(sin(theta)*u + cos(theta)*w)?<br>
<br>
How would I go about coding that? I just started learning the language a week ago. <br>
I have so far:<br>
<br>
theta = 0:100:2*pi;<br>
P = center+radius*(sin(theta)*N + cos(theta)*B);<br>
plot3(<br>
<br>
^ and I'm stuck on there, because you'd need X, Y, and Z. Do I go "P(1), P(2), P(3)"?<br>
<br>
Thanks again.

Tue, 19 Jul 2011 03:07:09 +0000
Re: a circle in 3D
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605#845865
Marie
"Marie " <mrvns3@gmail.com> wrote in message <j02s1o$rrc$1@newscl01ah.mathworks.com>...<br>
> "Roger Stafford" wrote in message <j02cvp$lq9$1@newscl01ah.mathworks.com>...<br>
> > "Roger Stafford" wrote in message <j02685$4hm$1@newscl01ah.mathworks.com>...<br>
> > > .......<br>
> > > I will give a method in terms of vector analysis and you can translate that into matlab code. Suppose u is a unit vector pointing from the center toward the point of tangency and v a unit vector normal to the osculating plane. Then w = cross(u,v) will be a unit vector orthogonal to u and v. Let c be the center point. Then all points P along the circle can be generated by:<br>
> > > <br>
> > > P = c + r*(sin(theta)*u + cos(theta)*w);<br>
> > > <br>
> > > for an angle theta which ranges from 0 to 2*pi and r the circle's radius.<br>
> > > .......<br>
> >         <br>
> > There is an easier way of thinking about your problem than the one I gave earlier. The first derivatives of the parametric equations that determine your space curve after being normalized to a unit vector tangent to the curve at the given point, give you the vector w I referred to. The vector u is determined from the second derivatives in the process of determining the location of the center of curvature and the radius. It is unnecessary to deal with the normal, v, to the osculating plane for generating the circle.<br>
> > <br>
> > Roger Stafford<br>
> <br>
> Thank you so much for your reply.<br>
> <br>
> Yes, I have the unit normal vector, unit tangent vector, the radius (found by 1/curvature), and the center point. <br>
> <br>
> So you're saying that "u" is on the normal vector, "v" is the tangent vector, and "w" (being cross(u,v)) is the binormal, and with c= center point and r = radius, I need to graph P = c + r*(sin(theta)*u + cos(theta)*w)?<br>
> <br>
> How would I go about coding that? I just started learning the language a week ago. <br>
> I have so far:<br>
> <br>
> theta = 0:100:2*pi;<br>
> P = center+radius*(sin(theta)*N + cos(theta)*B);<br>
> plot3(<br>
> <br>
> ^ and I'm stuck on there, because you'd need X, Y, and Z. Do I go "P(1), P(2), P(3)"?<br>
> <br>
> Thanks again.<br>
<br>
I also tried:<br>
<br>
theta = 0:100:2*pi;<br>
X = center(1)+radius*(sin(theta)*N(1) + cos(theta)*B(1));<br>
Y = center(2)+radius*(sin(theta)*N(2) + cos(theta)*B(2));<br>
Z = center(3)+radius*(sin(theta)*N(3) + cos(theta)*B(3));<br>
plot3(X,Y,Z,'r');<br>
<br>
but nothing is showing. What should I do?

Tue, 19 Jul 2011 06:05:09 +0000
Re: a circle in 3D
http://nl.mathworks.com/matlabcentral/newsreader/view_thread/310605#845876
Roger Stafford
"Marie " <mrvns3@gmail.com> wrote in message <j02sct$shl$1@newscl01ah.mathworks.com>...<br>
> "Marie " <mrvns3@gmail.com> wrote in message <j02s1o$rrc$1@newscl01ah.mathworks.com>...<br>
> > So you're saying that "u" is on the normal vector, "v" is the tangent vector, and "w" (being cross(u,v)) is the binormal, and with c= center point and r = radius, I need to graph P = c + r*(sin(theta)*u + cos(theta)*w)?<br>
> > ..........<br>
> > theta = 0:100:2*pi;<br>
> > P = center+radius*(sin(theta)*N + cos(theta)*B);<br>
> > ..........<br>
          <br>
No, the osculating circle should be formed by a combination of the unit tangent vector and the unit principal normal vector, which both lie in the osculating plane. The binormal vector is orthogonal to that plane and should not be used for this purpose.<br>
<br>
(The way I named them earlier, u was along the principal normal, v was the binormal and w was the tangent vector. I'm sorry if this nomenclature confused you. I should have named them differently.)<br>
<br>
In any case you should have something like:<br>
<br>
P = center+radius*(cos(theta)*N + sin(theta)*T)<br>
<br>
where N is the unit principal normal and T the unit tangent vector. (Reformulating it this way starts the plot at the point of tangency when theta is zero and then moves off in the unit tangent direction as theta increases.)<br>
<br>
If you form the 'center', N, and T as row vectors and 'theta' as a column vector, you can use the following vectorized method of computing P.<br>
<br>
n = 100;<br>
theta = linspace(0,2*pi,n).';<br>
P = bsxfun(@plus, center, radius*(cos(theta)*N+sin(theta)*T));<br>
<br>
You could equally well do this last as:<br>
<br>
P = repmat(center,n,1)+radius*(cos(theta)*N+sin(theta)*T);<br>
<br>
Then do:<br>
<br>
plot(P(:,1),P(:,2),P(:,3))<br>
<br>
Note: Your expression "theta = 0:100:2*pi" is incorrect. It should be something like: " theta = (0:2*pi/(n1):2*pi).' ". The 'linespace' function is probably easier to use, however.<br>
<br>
Roger Stafford