Klein bottle with unit normal vectors and Mobius band

Reference:[br][br][url=https://www.mathcurve.com/surfaces.gb/klein/klein.shtml]https://www.mathcurve.com/surfaces.gb/klein/klein.shtml[/url]
Script
#-------------------------------------------------[br]# I know it is a little messy but it works :)[br]#-------------------------------------------------[br][br][br]#-------------------------------------------------[br]# Define parameters[br]#-------------------------------------------------[br]size = 0.5[br]a = 3[br]b = 4[br]c = 2[br][br]#-------------------------------------------------[br]# Define components for Klein bottle[br]#-------------------------------------------------[br][br]F0(x, y) = size *( (a (1+ sin(x)) + c (1 - cos(x)/2) cos(y) ) cos(x) )[br]G0(x, y) = size * ( (b + c (1 - cos(x)/2) cos(y) ) sin(x) )[br]H0(x, y) = size * ( c (1 - cos(x)/2) sin(y) )[br][br]F1(x, y) = size *( a (1+ sin(x)) cos(x) - c (1 - cos(x)/2) cos(y) )[br]G1(x, y) = size * ( b sin(x) )[br]H1(x, y) = size * ( c (1 - cos(x)/2) sin(y) )[br][br]#-------------------------------------------------[br]# The Klein bottle is defined with 2 pieces[br]#-------------------------------------------------[br][br]Klein0 = Surface( F0(u, v), G0(u, v), H0(u, v), u, 0, pi, v, 0, 2 pi )[br]Klein1 = Surface( F1(u, v), G1(u, v), H1(u, v), u, pi, 2 pi, v, 0, 2 pi )[br][br]#-------------------------------------------------[br]# Now let's calculate normal vectors[br]#-------------------------------------------------[br][br]#a1[br]dF0x = Derivative(F0, x)[br]#b1[br]dF0y = Derivative(F0, y)[br]#a2[br]dG0x = Derivative(G0, x)[br]#b2[br]dG0y = Derivative(G0, y)[br]#a3[br]dH0x = Derivative(H0, x)[br]#b3[br]dH0y = Derivative(H0, y)[br][br]#a1[br]dF1x = Derivative(F1, x)[br]#b1[br]dF1y = Derivative(F1, y)[br]#a2[br]dG1x = Derivative(G1, x)[br]#b2[br]dG1y = Derivative(G1, y)[br]#a3[br]dH1x = Derivative(H1, x)[br]#b3[br]dH1y = Derivative(H1, y)[br][br]#(a2b3 - a3b2)i + (a3b1-a1b3)j + (a1b2-a2b1)k[br]P0x = dG0x * dH0y - dH0x * dG0y[br]P0y = dH0x * dF0y - dF0x * dH0y [br]P0z = dF0x * dG0y - dG0x * dF0y[br][br]#(a2b3 - a3b2)i + (a3b1-a1b3)j + (a1b2-a2b1)k[br]P1x = dG1x * dH1y - dH1x * dG1y[br]P1y = dH1x * dF1y - dF1x * dH1y [br]P1z = dF1x * dG1y - dG1x * dF1y[br][br]norm0 = sqrt( P0x^2 + P0y^2 + P0z^2 )[br][br]norm1 = sqrt( P1x^2 + P1y^2 + P1z^2 )[br][br]#-------------------------------------------------[br]# These will give the unitary normal vectors[br]#-------------------------------------------------[br][br]uN0x = P0x/norm0[br]uN0y = P0y/norm0[br]uN0z = P0z/norm0[br][br]uN1x = P1x/norm1[br]uN1y = P1y/norm1[br]uN1z = P1z/norm1[br][br][br]#-------------------------------------------------[br]# Now let's calcualte points to plot vectors[br]#-------------------------------------------------[br][br]Ax=Slider(0, 4pi, 0.01, 1, 120, false, true, false, false)[br]#Ay=Slider(0, 2pi, 0.01, 1, 120, false, true, false, false)[br][br]n= 25[br]Execute(Sequence("A"+i+" = Mod("+i+" 4 pi/n + Ax, 4 pi)", i, 1, n))[br][br]#If(Ax < π, Klein0(Ax, Ay), Klein1(Ax, Ay))[br]Execute(Sequence("B"+i+" = If(A"+i+" < pi, Klein0(A"+i+", pi/2), Klein1(A"+i+", pi/2))", i, 1, n))[br][br]Execute(Sequence("SetDynamicColor(B"+i+", "+i+"/n, 1, 1)", i, 1, n))[br][br]Execute(Sequence("ShowLabel(B"+i+", false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(B"+i+", 1, false)", i, 1, n))[br][br]#If(Ax < π, ( uN0x(Ax, pi/2), uN0y(Ax, pi/2), uN0z(Ax, pi/2) ), If( Ax < 2 pi, ( uN1x(Ax, pi/2), uN1y(Ax, pi/2), uN1z(Ax, pi/2) ), If( Ax < 3 pi, ( -uN0x(Ax, pi/2), -uN0y(Ax, pi/2), -uN0z(Ax, pi/2) ), ( -uN1x(Ax, pi/2), -uN1y(Ax, pi/2), -uN1z(Ax, pi/2) ) ) ) )[br][br]Execute(Sequence("C"+i+" = If(A"+i+" < π, ( uN0x(A"+i+", pi/2), uN0y(A"+i+", pi/2), uN0z(A"+i+", pi/2) ), If( A"+i+" < 2 pi, ( uN1x(A"+i+", pi/2), uN1y(A"+i+", pi/2), uN1z(A"+i+", pi/2) ), If( A"+i+" < 3 pi, ( -uN0x(A"+i+", pi/2), -uN0y(A"+i+", pi/2), -uN0z(A"+i+", pi/2) ), ( -uN1x(A"+i+", pi/2), -uN1y(A"+i+", pi/2), -uN1z(A"+i+", pi/2) ) ) ) )", i, 1, n))[br][br]Execute(Sequence("ShowLabel(C"+i+", false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(C"+i+", 1, false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(C"+i+", -1, false)", i, 1, n))[br][br]#-------------------------------------------------[br]# Finally, we plot vectors with colors :)[br]#-------------------------------------------------[br][br]#D = Translate(Vector((0,0,0), C), A)[br]Execute(Sequence("D"+i+" = Translate(Vector((0,0,0), C"+i+"), B"+i+")", i, 1, n))[br][br]Execute(Sequence("ShowLabel(D"+i+", false)", i, 1, n))[br]Execute(Sequence("SetVisibleInView(D"+i+", 1, false)", i, 1, n))[br][br]Execute(Sequence("SetDynamicColor(D"+i+", "+i+"/n, 1, 1)", i, 1, n))

Information: Klein bottle with unit normal vectors and Mobius band