Differences between revisions 12 and 31 (spanning 19 versions)
 ⇤ ← Revision 12 as of 2010-07-30 21:08:53 → Size: 7450 Editor: pang Comment: Added a new interact showing geodesics on a surface ← Revision 31 as of 2013-11-25 10:10:20 → ⇥ Size: 18496 Editor: pang Comment: Deletions are marked like this. Additions are marked like this. Line 6: Line 6: == Intersecting tetrahedral reflections == == Intersecting tetrahedral reflections FIXME == Line 8: Line 8: {{{ {{{#!sagecell Line 12: Line 12: p12 = p1.union(p2) p12 = p1.convex_hull(p2) Line 15: Line 15: p34 = p3.union(p4) p34 = p3.convex_hull(p4) Line 18: Line 18: p56 = p5.union(p6) p56 = p5.convex_hull(p6) Line 21: Line 21: p78 = p7.union(p8) p78 = p7.convex_hull(p8) Line 36: Line 36: {{{ {{{#!sagecell Line 52: Line 52: normal=(gammap[1]/norma(gammap), -gammap[0]/norma(gammap)) np=norma(gammap) Line 54: Line 54: np=norma(gammap) Line 57: Line 55: pe=gammap[0]*gammapp[0]+gammap[1]*gammapp[1] normal=(gammap[1]/np, -gammap[0]/np) Line 80: Line 79: show(grafica,aspect_ratio=1,xmin=-2,xmax=2,ymin=-2,ymax=2)}}} show(grafica,aspect_ratio=1,xmin=-2,xmax=2,ymin=-2,ymax=2)}}} Line 86: Line 86: {{{ {{{#!sagecell Line 92: Line 92: _int_u = input_grid(1, 2, default = [[0,pi]], label = 'u -interval'),       _int_v = input_grid(1, 2, default = [[-pi,pi]], label = 'v -interval')): x_int_u = input_grid(1, 2, default = [[0,pi]], label = 'u -interval'),       x_int_v = input_grid(1, 2, default = [[-pi,pi]], label = 'v -interval')): Line 96: Line 96: int_u = _int_u[0]    int_v = _int_v[0]        def F(uu, vv):         X = vector([x, y, z])         return X.subs({u : uu, v : vv})    S_plot = parametric_plot3d( F(u, v), int_u = x_int_u[0]    int_v = x_int_v[0]         F = vector([x, y, z])    S_plot = parametric_plot3d( F, Line 106: Line 104: show(S_plot, aspect_ratio = [1, 1, 1])        dFu = F(u, v).diff(u)    dFv = F(u, v).diff(v) S_plot.show(aspect_ratio = [1, 1, 1])        dFu = F.diff(u)    dFv = F.diff(v) Line 117: Line 115: dFtt = F(ufunc, vfunc).diff(t, t) dFtt = F(u=ufunc, v=vfunc).diff(t, t) Line 138: Line 136: Line 145: Line 143: }}}{{attachment:geodesics1.png}}{{{ }}}Second interact: now we draw the geodesics{{{#!sagecell Line 150: Line 152: @interactdef _(u_0 = slider(int_u[0], int_u[1], default = (int_u[0] + int_u[1])/2, label = 'u_0'),      v_0 = slider(int_v[0], int_v[1], default = (int_v[0] + int_v[1])/2, label = 'v_0'),      V_u = slider(-10, 10, default = 1, label = 'V_u'),      V_v = slider(-10, 10, default = 0, label = 'V_v'),       int_s = range_slider(-10, 10, 0.1,                            default = (0, (int_u[1] - int_u[0])/2),                            label = 'geodesic interval') ): 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@interactdef _(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')): Line 166: Line 182: y0 = [velocity[0], velocity[1], Point[0], Point[1]],                       t = srange(int_s[0], int_s[1], 0.01))                geo3D = [F(l,r) for [j, k, l, r] in geo2D_aux]                g_plot = line3d(geo3D, rgbcolor = (1, 0, 0), thickness = 4)                P = F(Point[0], Point[1])        P_plot = point3d((P[0], P[1], P[2]), rgbcolor = (0, 0, 0)) 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) Line 177: Line 196: V_plot = arrow3d(P, P + V) V_plot = arrow3d(P, P + V, color = 'black') Line 181: Line 200: {{attachment:geodesics1.png}} Line 182: Line 202: == Dimensional Explorer ==By Eviatar BachRenders 2D images (perspective or spring-layout) and 3D models of 0-10 dimensional hypercubes. It also displays number of edges and vertices.{{{#!sagecell@interactdef render(Display=selector(['2D Perspective', '2D Spring-layout', '3D']), Dimension=slider(0,10,default=4, step_size=1), Size=slider(0,10,default=5,step_size=1), Vertices=False, Calculations=False):        if Display=='2D Perspective':                if Dimension==0:            g=graphs.GridGraph([1])            print 'Vertices:', len(g.vertices()), ('(2^%s)'%Dimension if Calculations else ''), '\nEdges:', len(g.edges()), ('(%s*(%s/2))' %(len(g.vertices()), Dimension) if Calculations else '')            g.show(figsize=[Size,Size], vertex_size=30, vertex_labels=False, transparent=True, vertex_colors='black')                    else:            g=graphs.CubeGraph(Dimension)            print 'Vertices:', len(g.vertices()), ('(2^%s)'%Dimension if Calculations else ''), '\nEdges:', len(g.edges()), ('(%s*(%s/2))' %(len(g.vertices()), Dimension) if Calculations else '')            g.show(figsize=[Size,Size], vertex_size=(20 if Vertices else 0), vertex_labels=False, transparent=True, vertex_colors='black')                if Display=='2D Spring-layout':                if Dimension==0:            s=graphs.GridGraph([1])            print 'Vertices:', len(s.vertices()), ('(2^%s)'%Dimension if Calculations else ''), '\nEdges:', len(s.edges()), ('(%s*(%s/2))' %(len(s.vertices()), Dimension) if Calculations else '')            s.show(figsize=[Size,Size], vertex_size=30, vertex_labels=False, transparent=True, vertex_colors='black')                    else:            s=graphs.GridGraph([2]*Dimension)            print 'Vertices:', len(s.vertices()), ('(2^%s)'%Dimension if Calculations else ''), '\nEdges:', len(s.edges()), ('(%s*(%s/2))' %(len(s.vertices()), Dimension) if Calculations else '')            s.show(figsize=[Size,Size], vertex_size=(20 if Vertices else 0), vertex_labels=False, transparent=True, vertex_colors='black')                if Display=='3D':        if Dimension==0:            d=graphs.GridGraph([1])            print 'Vertices:', len(d.vertices()), ('(2^%s)'%Dimension if Calculations else ''), '\nEdges:', len(d.edges()), ('(%s*(%s/2))' %(len(d.vertices()), Dimension) if Calculations else '')            d.show3d(figsize=[Size/2,Size/2], vertex_size=0.001)        else:            d=graphs.CubeGraph(Dimension)            print 'Vertices:', len(d.vertices()), ('(2^%s)'%Dimension if Calculations else ''), '\nEdges:', len(d.edges()), ('(%s*(%s/2))' %(len(d.vertices()), Dimension) if Calculations else '')            d.show3d(figsize=[Size,Size], vertex_size=(0.03 if Vertices else 0.001))}}}{{attachment:dimensions.png}}== Crofton's formula ==by Pablo Angulo. Illustrates [[http://en.wikipedia.org/wiki/Crofton%27s_formula| Crofton's formula]] by throwing some random lines and computing the intersection number with a given curve. May use either solve for exact computation of the intersections, or may also approximate the curve by straight segments (this is the default).{{{#!sagecellfrom collections import defaultdictvar('t x y')pin = pi.n()def longitud(curva, t0, t1):    dxdt = derivative(curva[0], t)    dydt = derivative(curva[1], t)    integrando(t) = sqrt(dxdt^2 + dydt^2)    i,_ = numerical_integral(integrando, t0, t1)    return idef random_line(cota):    theta = random()*pin    k = 2*cota*random() - cota    return sin(theta)*x + cos(theta)*y + kdef crofton_exact(curva, t0, t1, L, M):    forget()    assume(t>t0)    assume(t

# Sage Interactions - Geometry

## Intersecting tetrahedral reflections FIXME

by Marshall Hampton. Inspired by a question from Hans Schepker of Glass Geometry.

## Evolutes

by Pablo Angulo. Computes the evolute of a plane curve given in parametric coordinates. The curve must be parametrized from the interval [0,2pi].

## Geodesics on a parametric surface

by Antonio Valdés and Pablo Angulo. A first interact allows the user to introduce a parametric surface, and draws it. Then a second interact draws a geodesic within the surface. The separation is so that after the first interact, the geodesic equations are "compiled", and then the second interact is faster.

Second interact: now we draw the geodesics

## Dimensional Explorer

By Eviatar Bach

Renders 2D images (perspective or spring-layout) and 3D models of 0-10 dimensional hypercubes. It also displays number of edges and vertices.

## Crofton's formula

by Pablo Angulo. Illustrates Crofton's formula by throwing some random lines and computing the intersection number with a given curve. May use either solve for exact computation of the intersections, or may also approximate the curve by straight segments (this is the default).

## Banchoff-Pohl area

by Pablo Angulo. Computes the Banchoff-Pohl "area enclosed by a spatial curve", by throwing some random lines and computing the linking number with the given curve. Lines not linked to the given curve are displayed in red, linked lines are displayed in green.

interact/geometry (last edited 2019-11-15 08:20:36 by chapoton)