# Klein bottle with unit normal vectors and Mobius band

Topic:
Vectors

## Script

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