Ask Your Question
2

Embedding a graphics/plot on a torus

asked 2014-01-13 13:02:06 +0100

Steven gravatar image

updated 2014-01-13 13:24:55 +0100

Hi, I'm currently trying to embed a plot on the surface of a Torus. Say I have a plot or an image of size $(2 \pi R$ , $2 \pi r)$, and a Torus of:

  • radius from the center to the center of the tube equal to $R$
  • radius of the tube equal to $r$.

Is the a way I can embed this plot to the surface of the torus?

Right now I am able to plot both the Torus (using parametric_plot3d) and the other image.

The other plot is composed by vertices and straight lines between the vertices (actually it is a graph). I already thought of mapping the coordinates of the vertices to the 3d coordinates of the torus but this would produce straight lines that cross the tube, instead of passing over the surface.

I can also specify the coordinates of the vertices and plot the graph object, but the same problem arises. Also, some other objects might appear on the plot (think of rectangles) and it would be nice to correctly embed that ones too. Maybe the easiest solution is just to save the plot to an image and the apply this "texture" to a torus?

If this is not possible/easy to do in sage, which software would you recommend?

Edit: the result should be something like this (ignore the animation): http://upload.wikimedia.org/wikipedia...

Thank you very much.

PS: Just out of curiosity, can this be generalized by applying a "texture" to an arbitrary surface?

edit retag flag offensive close merge delete

Comments

Ah, the Tonnetz! Love Neo-Riemannian theory... Anyway, just as a comment, have you tried creating the edges of your graph as parametric curves within the parametric surface? That would be the first thing that would occur to me, though I agree it requires a substantial amount more work than if the graph just automatically "knew" it lived on the torus.

kcrisman gravatar imagekcrisman ( 2014-01-13 14:52:00 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-01-13 16:24:41 +0100

niles gravatar image

I don't know how to do texture maps, although it might be possible (see, e.g., this question about color maps). But you might be able to work around this if you can write your graph as a parametrized curve or union thereof. Then just compose with the parametrizing functions for the torus and plot! Here's an example that I was working on for something else but seems useful here :)

# Parametric equations for a torus; the fundamental domain is the square [0,2*pi] x [0,2*pi]
sage: var('u,v');
sage: a,b = 2,1 # outer and inner radii
sage: x = (a + b*cos(u))*cos(v)
sage: y = (a + b*cos(u))*sin(v)
sage: z = b*sin(u)

# A parametric curve (line) in the u-v plane
sage: var('t');
sage: c = (2*t,3*t)

sage: # the same curve in cartesian coordinates on the torus
sage: s = [_.subs(dict(zip((u,v),c))) for _ in (x,y,z)]
sage: s
[(cos(2*t) + 2)*cos(3*t), (cos(2*t) + 2)*sin(3*t), sin(2*t)]

sage: curve = parametric_plot(s,(t,0,2*pi),color='red',thickness=2,plot_points=400)
sage: T = parametric_plot3d([x,y,z], (u,0,2*pi),(v,0,2*pi), opacity=.6,aspect_ratio=1) 
sage: T+curve

And here's a slightly fancier example with more curves:

sage: plane_curves = [(i*2*pi/5 + 2*t,3*t) for i in range(5)]+[(i*2*pi/5 + 3*t,-2*t) for i in range(5)]
sage: torus_curves = [[_.subs(dict(zip((u,v),c))) for _ in (x,y,z)] for c in plane_curves]
sage: curve_plots = [parametric_plot(torus_curves[i], (t,0,2*pi), color=hue(2*i/10), thickness=4, plot_points=400) for i in range(10)]

sage: from sage.plot.plot3d.base import Graphics3d # initial term for sum below    
sage: T + sum(curve_plots,Graphics3d())

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-01-13 13:02:06 +0100

Seen: 1,869 times

Last updated: Jan 13 '14