Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
a circle in 3D

Subject: a circle in 3D

From: Marie

Date: 18 Jul, 2011 19:47:08

Message: 1 of 6

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?

What I have so far:

    THETA = linspace(0,2*pi,100);
    RHO = ones(1,100)*radius;
    [X,Y] = pol2cart(THETA,RHO);
    X = X+center(1);
    Y = Y+center(2);
    Z = center(3)*ones(1,length(X));
    H = plot3(X,Y,Z,'r');
    
But all this does this graph the circle in X-Y 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)).

I guess what I'm wondering is if there's a similar function to pol2cart, except with Z added in?

Thanks so much.

Subject: a circle in 3D

From: Roger Stafford

Date: 18 Jul, 2011 20:49:09

Message: 2 of 6

"Marie " <mrvns3@gmail.com> wrote in message <j022js$mr5$1@newscl01ah.mathworks.com>...
> 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?
> .......
- - - - - - - - - - -
  You need more than just a radius and center to determine a three-dimensional 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.

  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:

  P = c + r*(sin(theta)*u + cos(theta)*w);

for an angle theta which ranges from 0 to 2*pi and r the circle's radius.

  Does that help you?

  (Note: You also need those same derivatives mentioned above for determining the radius and center.)

Roger Stafford

Subject: a circle in 3D

From: Roger Stafford

Date: 18 Jul, 2011 22:44:09

Message: 3 of 6

"Roger Stafford" wrote in message <j02685$4hm$1@newscl01ah.mathworks.com>...
> .......
> 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:
>
> P = c + r*(sin(theta)*u + cos(theta)*w);
>
> for an angle theta which ranges from 0 to 2*pi and r the circle's radius.
> .......
- - - - - - - - -
  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.

Roger Stafford

Subject: a circle in 3D

From: Marie

Date: 19 Jul, 2011 03:01:12

Message: 4 of 6

"Roger Stafford" wrote in message <j02cvp$lq9$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <j02685$4hm$1@newscl01ah.mathworks.com>...
> > .......
> > 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:
> >
> > P = c + r*(sin(theta)*u + cos(theta)*w);
> >
> > for an angle theta which ranges from 0 to 2*pi and r the circle's radius.
> > .......
> - - - - - - - - -
> 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.
>
> Roger Stafford

Thank you so much for your reply.

Yes, I have the unit normal vector, unit tangent vector, the radius (found by 1/curvature), and the center point.

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)?

How would I go about coding that? I just started learning the language a week ago.
I have so far:

theta = 0:100:2*pi;
P = center+radius*(sin(theta)*N + cos(theta)*B);
plot3(

^ and I'm stuck on there, because you'd need X, Y, and Z. Do I go "P(1), P(2), P(3)"?

Thanks again.

Subject: a circle in 3D

From: Marie

Date: 19 Jul, 2011 03:07:09

Message: 5 of 6

"Marie " <mrvns3@gmail.com> wrote in message <j02s1o$rrc$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <j02cvp$lq9$1@newscl01ah.mathworks.com>...
> > "Roger Stafford" wrote in message <j02685$4hm$1@newscl01ah.mathworks.com>...
> > > .......
> > > 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:
> > >
> > > P = c + r*(sin(theta)*u + cos(theta)*w);
> > >
> > > for an angle theta which ranges from 0 to 2*pi and r the circle's radius.
> > > .......
> > - - - - - - - - -
> > 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.
> >
> > Roger Stafford
>
> Thank you so much for your reply.
>
> Yes, I have the unit normal vector, unit tangent vector, the radius (found by 1/curvature), and the center point.
>
> 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)?
>
> How would I go about coding that? I just started learning the language a week ago.
> I have so far:
>
> theta = 0:100:2*pi;
> P = center+radius*(sin(theta)*N + cos(theta)*B);
> plot3(
>
> ^ and I'm stuck on there, because you'd need X, Y, and Z. Do I go "P(1), P(2), P(3)"?
>
> Thanks again.

I also tried:

theta = 0:100:2*pi;
X = center(1)+radius*(sin(theta)*N(1) + cos(theta)*B(1));
Y = center(2)+radius*(sin(theta)*N(2) + cos(theta)*B(2));
Z = center(3)+radius*(sin(theta)*N(3) + cos(theta)*B(3));
plot3(X,Y,Z,'r');

but nothing is showing. What should I do?

Subject: a circle in 3D

From: Roger Stafford

Date: 19 Jul, 2011 06:05:09

Message: 6 of 6

"Marie " <mrvns3@gmail.com> wrote in message <j02sct$shl$1@newscl01ah.mathworks.com>...
> "Marie " <mrvns3@gmail.com> wrote in message <j02s1o$rrc$1@newscl01ah.mathworks.com>...
> > 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)?
> > ..........
> > theta = 0:100:2*pi;
> > P = center+radius*(sin(theta)*N + cos(theta)*B);
> > ..........
- - - - - - - - - - -
  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.

  (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.)

  In any case you should have something like:

 P = center+radius*(-cos(theta)*N + sin(theta)*T)

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.)

  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.

 n = 100;
 theta = linspace(0,2*pi,n).';
 P = bsxfun(@plus, center, radius*(-cos(theta)*N+sin(theta)*T));

You could equally well do this last as:

 P = repmat(center,n,1)+radius*(-cos(theta)*N+sin(theta)*T);

Then do:

 plot(P(:,1),P(:,2),P(:,3))

  Note: Your expression "theta = 0:100:2*pi" is incorrect. It should be something like: " theta = (0:2*pi/(n-1):2*pi).' ". The 'linespace' function is probably easier to use, however.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us