MATLAB: Rotate Normal Around Tangent

circlerotationvector

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.

Best Answer

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