# position x(t) = 2 * sin(t) y(t) = sin(2 * t) z(t) = cos(t) / 2 # size w(t) = 0.25 # moebius twist mc(t) = cos(t / 2) ms(t) = sin(t / 2) # d = d/dt position dx(t) = 2 * cos(t) dy(t) = 2 * cos(2 * t) dz(t) = -sin(t) / 2 dl(t) = sqrt(dx(t)**2 + dy(t)**2 + dz(t)**2) # u = unit d ux(t) = dx(t) / dl(t) uy(t) = dy(t) / dl(t) uz(t) = dz(t) / dl(t) # a = (0,0,1) `cross` u ax(t) = -uy(t) ay(t) = ux(t) az(t) = 0 # b = a `cross` u bx(t) = ay(t) * uz(t) - az(t) * uy(t) by(t) = az(t) * ux(t) - ax(t) * uz(t) bz(t) = ax(t) * uy(t) - ay(t) * ux(t) bl(t) = sqrt(bx(t)**2 + by(t)**2 + bz(t)**2) # v = unit b vx(t) = bx(t) / bl(t) vy(t) = by(t) / bl(t) vz(t) = bz(t) / bl(t) # c = v `cross` u cx(t) = vy(t) * uz(t) - vz(t) * uy(t) cy(t) = vz(t) * ux(t) - vx(t) * uz(t) cz(t) = vx(t) * uy(t) - vy(t) * ux(t) cl(t) = sqrt(cx(t)**2 + cy(t)**2 + cz(t)**2) # w = unit c wx(t) = cx(t) / cl(t) wy(t) = cy(t) / cl(t) wz(t) = cz(t) / cl(t) # p = mc * v + ms * w px(t) = mc(t) * vx(t) + ms(t) * wx(t) py(t) = mc(t) * vy(t) + ms(t) * wy(t) pz(t) = mc(t) * vz(t) + ms(t) * wz(t) # q = -ms * v + mc * w qx(t) = -ms(t) * vx(t) + mc(t) * wx(t) qy(t) = -ms(t) * vy(t) + mc(t) * wy(t) qz(t) = -ms(t) * vz(t) + mc(t) * wz(t) # i1 = position + width * p i1x(t) = x(t) + w(t) * px(t) i1y(t) = y(t) + w(t) * py(t) i1z(t) = z(t) + w(t) * pz(t) # j1 = position + width * q j1x(t) = x(t) + w(t) * qx(t) j1y(t) = y(t) + w(t) * qy(t) j1z(t) = z(t) + w(t) * qz(t) # k = mix(i1, j1, t) k1x(t,s) = i1x(t) * (1 - s) + s * j1x(t) k1y(t,s) = i1y(t) * (1 - s) + s * j1y(t) k1z(t,s) = i1z(t) * (1 - s) + s * j1z(t) # i2 = position + width * q i2x(t) = x(t) + w(t) * qx(t) i2y(t) = y(t) + w(t) * qy(t) i2z(t) = z(t) + w(t) * qz(t) # j1 = position - width * p j2x(t) = x(t) - w(t) * px(t) j2y(t) = y(t) - w(t) * py(t) j2z(t) = z(t) - w(t) * pz(t) # k = mix(i1, j1, t) k2x(t,s) = i2x(t) * (1 - s) + s * j2x(t) k2y(t,s) = i2y(t) * (1 - s) + s * j2y(t) k2z(t,s) = i2z(t) * (1 - s) + s * j2z(t) # margins set lmargin at screen 0.05 set rmargin at screen 0.95 set bmargin at screen 0.05 set tmargin at screen 0.95 # decorations unset border unset key unset tics # background grey set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#808080" behind set palette defined (0 '#000000') set palette defined (1 '#ffffff') set pm3d depthorder set hidden3d set style fill solid # should be odd set isosamples 361,2 set view 0,0 # parametric set parametric # plot to tables set table 'moebius-1.dat' splot [u=-2*pi:2*pi][v=0:1] k1x(u,v),k1y(u,v),k1z(u,v) set table 'moebius-2.dat splot [u=-2*pi:2*pi][v=0:1] k2x(u,v),k2y(u,v),k2z(u,v) unset table # output file set terminal pngcairo enhanced size 1920,1080 set output 'moebius.png' # plot from tables splot \ 'moebius-1.dat' u 1:2:3:(0) w pm3d, \ 'moebius-2.dat' u 1:2:3:(1) w pm3d