Torus Knot Code in Matlab, Assignments of Programming Languages

code for Matlab used for building a Torus Knot. I used it for my programming language course for this year of school

Typology: Assignments

2019/2020

Uploaded on 08/22/2020

ralucica
ralucica 🇬🇧

1 document

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Bulding a Torus Knot
matlab code (guide)
phi=str2double(get(handles.edit1,'String'));
q=str2double(get(handles.edit2,'String'));
C=str2double(get(handles.edit3,'String'))
theta=linspace(0,2*pi,200);
r=cos(q.*theta)+2;
x=r.*(cos(phi.*theta));
y=r.*(sin(phi.*theta));
z=-(sin(q.*theta));
C=min((phi-1).*q,(q-1).*phi) %%crossing number
(r-2).^2+z.^2==1;
axis(handles.axes1)
cla
plot3(x,y,z,'-y','LineWidth',2);
axis equal
axis off
rotate3d on
xlabel('X','fontSize',14);
ylabel('Y','fontSize',14);
zlabel('Z','fontsize',14);
title('Torus knot','fontsize',15)

Partial preview of the text

Download Torus Knot Code in Matlab and more Assignments Programming Languages in PDF only on Docsity!

Bulding a Torus Knot

matlab code (guide)

phi=str2double(get(handles.edit1,'String')); q=str2double(get(handles.edit2,'String')); C=str2double(get(handles.edit3,'String')) theta=linspace(0,2pi,200); r=cos(q.theta)+2; x=r.(cos(phi.theta)); y=r.(sin(phi.theta)); z=-(sin(q.theta)); C=min((phi-1).q,(q-1).*phi) %%crossing number (r-2).^2+z.^2==1; axis(handles.axes1) cla plot3(x,y,z,'-y','LineWidth',2); axis equal axis off rotate3d on xlabel('X','fontSize',14); ylabel('Y','fontSize',14); zlabel('Z','fontsize',14); title('Torus knot','fontsize',15)