Rotate Normal Around Tangent

I want to rotate a normal vector around a tangent vector to create a circle. I have not been able to find anything to do this. Does such a function exist? Or how would I generate one?
Thanks.

2 Comments

Clarify what this is supposed to do. What data are you given and in what form? What will the output data be, and in what form?
I have a 3D curve, and I have calculated normal and tangent vectors at each point on the curve based on a velocity (I am using Frenet-frame here). I want to be able to draw a 3D circle that is normal to the curve at some points (not all...there are a lot of points...). I figured the best way would be to rotate the normal vector about the tangent vector.

Sign in to comment.

 Accepted Answer

Matt J
Matt J on 6 Oct 2012
Edited: Matt J on 6 Oct 2012
I'm assuming you're choosing the radius, R, of this circle. Then if T and N are the tangent and normal vectors at point P on the curve (all in column vector form):
n=1000;
theta=linspace(0,2*pi,n+1);
theta(end)=[];
refcircle = [R*cos(theta);R*sin(theta);zeros(1,n);ones(1,n)] ;
T=T/norm(T);
N=N/norm(N);
E=cross(N,T);
A=[0 0 0; R 0 0; 0 R 0].';
B=[P,P+R*N,P+R*E];
params=absor(A,B); %get this function from FEX
C = params.M*refcircle; %circle points at 3D curve
plot3(C(1,:), C(2,:), C(3,:)) %plot the circle
The above uses ABSOR, available here

8 Comments

Two things: * What is "P"? Is this supposed to be T? * Is there any way to do this without ABSOR? I have a problem with getting code from home to work, so if I could get a solution that does not use this function (which is rather large...), I would appreciate that
I appreciate the help - this looks like a good solution, aside from the big external function.
Thanks!
Matt J
Matt J on 6 Oct 2012
Edited: Matt J on 6 Oct 2012
As I mentioned in the preamble to the code "T and N are the tangent and normal vectors at point P on the curve". Here's an alternative sans-ABSOR
n=1000;
theta=linspace(0,2*pi,n+1);
theta(end)=[];
refcircle = [R*cos(theta);R*sin(theta)] ;
T=T/norm(T);
N=N/norm(N);
C=bsxfun(@plus, [N,T]*refcircle, P);
plot3(C(1,:), C(2,:), C(3,:)) %plot the circle
Whoops, I read the reply, then forgot about it when reading the code. I appreciate the help.
There seems to be a problem when I multiply [N, T] by refcircle. refcircle as 1000 columns and [N, T] may be two columns. How do I fix this?
Matt J
Matt J on 7 Oct 2012
Edited: Matt J on 7 Oct 2012
There's nothing wrong with refcircle having more than 2 columns. Since this is matrix multiplication, it's only critical that refcircle have 2 rows. I've tested all versions of the routine before giving them to you and they run with no MATLAB errors on my end.
One small issue, though, is that I did have the circle tangent to the curve instead of normal to it. The version below should fix that.
n=1000;
theta=linspace(0,2*pi,n+1);
theta(end)=[];
refcircle = [R*cos(theta);R*sin(theta)] ;
T=T/norm(T);
N=N/norm(N);
E=cross(N,T);
C=bsxfun(@plus, [N,E]*refcircle, P);
plot3(C(1,:), C(2,:), C(3,:)) %plot the circle
Alright, I got it. However, when I plot, I end up with a bunch of lines (which are normal to the curve). Maybe they are long thin ovals, but they are certainly not circles. Again, any help is appreciated.
Matt J
Matt J on 7 Oct 2012
Edited: Matt J on 7 Oct 2012
Clarify whether the plot you're talking about is from the code as I gave it to you, or the result of you adapting/inserting it into your larger problem. If the latter, I'd have to see what you did.
However, when I run it in isolation with the sample data P,T,N,R data below, I definitely get a plot of a circle floating in 3D space. Verify first that you can reproduce this.
P=[1;1;1];
T=[1;1;1];
N=[-1;2;-1];
R=3;
n=1000;
theta=linspace(0,2*pi,n+1);
theta(end)=[];
refcircle = [R*cos(theta);R*sin(theta)] ;
T=T/norm(T);
N=N/norm(N);
E=cross(N,T);
C=bsxfun(@plus, [N,E]*refcircle, P);
plot3(C(1,:), C(2,:), C(3,:)) %plot the circle
Turns out the way I was calculating my tangent/normal vectors was doing them as row-vectors, not columns. Looking at the way you did it (with columns) got it to work.
Thanks for your help.

Sign in to comment.

More Answers (2)

Muthu Annamalai
Muthu Annamalai on 5 Oct 2012
Paul, You need to find the points of a 2D rotation transform using the equations, for example affine transformation http://en.wikipedia.org/wiki/Rotation_(mathematics), and then you may visualize it using plot() commands. HTH, -Muthu

1 Comment

As stated above, I am calculating Frenet-frame vectors, which I have (in the past) used to generate a rotation matrix (3D). Is this same rotation matrix going to allow me to draw a circle perpendicular to the curve (i.e. by multiplying the x, y, z points of a circle by the rotation matrix)?

Sign in to comment.

Image Analyst
Image Analyst on 6 Oct 2012
Edited: Image Analyst on 6 Oct 2012
Sounds like the streamtube() function. Could that be used? Or maybe morphological dilation, imdilate(). For morphological dilation, imagine a sphere whose center is tracing out your 3D curve. The dilated volumetric image is the volume swept out by that sphere as it travels along your curve.

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!