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:
Plotting circle tangent to a curve in 3d

Subject: Plotting circle tangent to a curve in 3d

From: Edward Tan

Date: 1 Mar, 2012 14:10:17

Message: 1 of 7

Hi,
    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.

Thanks
Edward

Subject: Plotting circle tangent to a curve in 3d

From: Roger Stafford

Date: 1 Mar, 2012 20:38:12

Message: 2 of 7

"Edward Tan" <octrs@hotmail.com> wrote in message <jio009$84g$1@newscl01ah.mathworks.com>...
> Hi,
> 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.
>
> Thanks
> Edward
- - - - - - - -
  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:

 P10 = P1-P0;
 P20 = P2-P0;
 N = dot(P10,P10)*P20-dot(P20,P20)*P10; % <-- Approx. tangent direction
 T = null(N).'; % Get two orthogonal unit vectors which are orthog. to N
 theta = linspace(0,2*pi).';
 V = bsxfun(@plus,R*(cos(theta)*T(1,:)+sin(theta)*T(2,:)),P0);
 plot3(V(:,1),V(:,2),V(:,3))

  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.

Roger Stafford

Subject: Plotting circle tangent to a curve in 3d

From: Edward Tan

Date: 1 Mar, 2012 22:18:12

Message: 3 of 7

Hi Roger,
    Thank you very much for your help. It works and thank you for the detail explanation.

Have a nice day
Edward

"Roger Stafford" wrote in message <jiomnj$t63$1@newscl01ah.mathworks.com>...
> "Edward Tan" <octrs@hotmail.com> wrote in message <jio009$84g$1@newscl01ah.mathworks.com>...
> > Hi,
> > 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.
> >
> > Thanks
> > Edward
> - - - - - - - -
> 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:
>
> P10 = P1-P0;
> P20 = P2-P0;
> N = dot(P10,P10)*P20-dot(P20,P20)*P10; % <-- Approx. tangent direction
> T = null(N).'; % Get two orthogonal unit vectors which are orthog. to N
> theta = linspace(0,2*pi).';
> V = bsxfun(@plus,R*(cos(theta)*T(1,:)+sin(theta)*T(2,:)),P0);
> plot3(V(:,1),V(:,2),V(:,3))
>
> 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.
>
> Roger Stafford

Subject: Plotting circle tangent to a curve in 3d

From: Roger Stafford

Date: 2 Mar, 2012 01:41:12

Message: 4 of 7

"Edward Tan" <octrs@hotmail.com> wrote in message <jiosj4$k5c$1@newscl01ah.mathworks.com>...
> Thank you very much for your help. It works and thank you for the detail explanation.
> "Roger Stafford" wrote in message <jiomnj$t63$1@newscl01ah.mathworks.com>...
> > N = dot(P10,P10)*P20-dot(P20,P20)*P10; % <-- Approx. tangent direction
- - - - - - - - -
  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.

Roger Stafford

Subject: Plotting circle tangent to a curve in 3d

From: Edward Tan

Date: 15 Mar, 2012 19:40:34

Message: 5 of 7

"Roger Stafford" wrote in message <jip8fo$p8k$1@newscl01ah.mathworks.com>...
> "Edward Tan" <octrs@hotmail.com> wrote in message <jiosj4$k5c$1@newscl01ah.mathworks.com>...
> > Thank you very much for your help. It works and thank you for the detail explanation.
> > "Roger Stafford" wrote in message <jiomnj$t63$1@newscl01ah.mathworks.com>...
> > > N = dot(P10,P10)*P20-dot(P20,P20)*P10; % <-- Approx. tangent direction
> - - - - - - - - -
> 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.
>
> Roger Stafford

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?

Thanks and have a nice day
Edward
 

Subject: Plotting circle tangent to a curve in 3d

From: Roger Stafford

Date: 15 Mar, 2012 23:38:21

Message: 6 of 7

"Edward Tan" <octrs@hotmail.com> wrote in message <jjtgji$75v$1@newscl01ah.mathworks.com>...
> 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?
- - - - - - - - - - -
  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.

Roger Stafford

Subject: Plotting circle tangent to a curve in 3d

From: Edward Tan

Date: 16 Mar, 2012 17:08:11

Message: 7 of 7

"Roger Stafford" wrote in message <jjtuhd$kfv$1@newscl01ah.mathworks.com>...
> "Edward Tan" <octrs@hotmail.com> wrote in message <jjtgji$75v$1@newscl01ah.mathworks.com>...
> > 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?
> - - - - - - - - - - -
> 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.
>
> Roger Stafford

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.

Edward

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