Diff Geom

115 days ago by elliptic

u,v,t = var('u,v,t'); r = 1; cylinder = parametric_plot3d([r*cos(u),r*sin(u),v],(u,0,2*pi),(v,0,2), color ='green'); strake = parametric_plot3d([((1-t)*r+2*t)*cos(u),((1-t)*r+2*t)*sin(u),u/pi],(u,0,2*pi),(t,0,1),color = 'blue'); cylinder + strake 
       
r = 0; helicoid = parametric_plot3d([((1-t)*r+2*t)*cos(u),((1-t)*r+2*t)*sin(u),u/pi],(u,0,2*pi),(t,0,1),color = 'yellow'); helicoid 
       
u, v, t = var('u v t') @interact def _(x = input_box(3*sin(u)*cos(v), 'x'), y = input_box(sin(u)*sin(v), 'y'), z = input_box(2*cos(u), 'z'), _int_u = input_grid(1, 2, default = [[0,pi]], label = 'u -interval'), _int_v = input_grid(1, 2, default = [[-pi,pi]], label = 'v -interval')): global F, Fu, Fv, func, S_plot, int_u, int_v int_u = _int_u[0] int_v = _int_v[0] F = vector([x, y, z]) S_plot = parametric_plot3d( F, (u, int_u[0], int_u[1]), (v, int_v[0], int_v[1])) S_plot.show(aspect_ratio = [1, 1, 1]) dFu = F.diff(u) dFv = F.diff(v) Fu = fast_float(dFu, u, v) Fv = fast_float(dFv, u, v) ufunc = function('ufunc', t) vfunc = function('vfunc', t) dFtt = F(u=ufunc, v=vfunc).diff(t, t) ec1 = dFtt.dot_product(dFu(u=ufunc, v=vfunc)) ec2 = dFtt.dot_product(dFv(u=ufunc, v=vfunc)) dv, ddv, du, ddu = var('dv, ddv, du, ddu') diffec1 = ec1.subs_expr(diff(ufunc, t) == du, diff(ufunc, t, t) == ddu, diff(vfunc, t) == dv, diff(vfunc, t, t) == ddv, ufunc == u, vfunc == v) diffec2 = ec2.subs_expr(diff(ufunc, t) == du, diff(ufunc, t, t) == ddu, diff(vfunc, t) == dv, diff(vfunc, t, t) == ddv, ufunc == u, vfunc == v) sols = solve([diffec1 == 0 , diffec2 == 0], ddu, ddv) ddu_rhs = (sols[0][0]).rhs().full_simplify() ddv_rhs = (sols[0][1]).rhs().full_simplify() ddu_ff = fast_float(ddu_rhs, du, dv, u, v) ddv_ff = fast_float(ddv_rhs, du, dv, u, v) def func(y,t): v = list(y) return [ddu_ff(*v), ddv_ff(*v), v[0], v[1]] 
       
u -interval 
v -interval 

Click to the left again to hide and once more to show the dynamic interactive window

from scipy.integrate import odeint def fading_line3d(points, rgbcolor1, rgbcolor2, *args, **kwds): L = len(points) vcolor1 = vector(RDF, rgbcolor1) vcolor2 = vector(RDF, rgbcolor2) return sum(line3d(points[j:j+2], rgbcolor = tuple( ((L-j)/L)*vcolor1 + (j/L)*vcolor2 ), *args, **kwds) for j in srange(L-1)) steps = 100 @interact def _(u_0 = slider(int_u[0], int_u[1], (int_u[1] - int_u[0])/100, default = (int_u[0] + int_u[1])/2, label = 'u_0'), v_0 = slider(int_v[0], int_v[1], (int_v[1] - int_v[0])/100, default = (int_v[0] + int_v[1])/2, label = 'v_0'), V_u = slider(-10, 10, 1/10, default = 1, label = 'V_u'), V_v = slider(-10, 10, 1/10, default = 0, label = 'V_v'), int_s = slider(0, 10, 1/10, default = (int_u[1] - int_u[0])/2, label = 'geodesic interval'), sliding_color = checkbox(True,'change color along the geodesic')): du, dv, u, v = var('du dv u v') Point = [u_0, v_0] velocity = [V_u, V_v] Point = map(float, Point) velocity = map(float, velocity) geo2D_aux = odeint(func, y0 = [velocity[0], velocity[1], Point[0], Point[1]], t = srange(0, int_s, 0.01)) geo3D = [F(u=l,v=r) for [j, k, l, r] in geo2D_aux] if sliding_color: g_plot = fading_line3d(geo3D, rgbcolor1 = (1, 0, 0), rgbcolor2 = (0, 1, 0), thickness=4) else: g_plot = line3d(geo3D, rgbcolor=(0, 1, 0), thickness=4) P = F(u=Point[0], v=Point[1]) P_plot = point3d((P[0], P[1], P[2]), rgbcolor = (0, 0, 0), pointsize = 30) V = velocity[0] * Fu(u = Point[0], v = Point[1]) + \ velocity[1] * Fv(u= Point[0], v = Point[1]) V_plot = arrow3d(P, P + V, color = 'black') show(g_plot + S_plot + V_plot + P_plot,aspect_ratio = [1, 1, 1]) 
       
u_0 
v_0 
V_u 
V_v 
geodesic interval 
change color along the geodesic 

Click to the left again to hide and once more to show the dynamic interactive window