Ask Your Question

Steven's profile - activity

2017-04-12 15:31:47 +0200 received badge  Famous Question (source)
2017-02-23 20:58:53 +0200 received badge  Famous Question (source)
2017-02-23 20:58:53 +0200 received badge  Notable Question (source)
2015-12-01 12:25:03 +0200 received badge  Nice Question (source)
2015-12-01 12:21:31 +0200 received badge  Notable Question (source)
2015-03-05 15:06:23 +0200 received badge  Popular Question (source)
2014-12-11 11:32:48 +0200 received badge  Popular Question (source)
2014-01-13 13:02:06 +0200 asked a question Embedding a graphics/plot on a torus

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?

2013-01-14 12:07:27 +0200 commented answer How to use cython functions from other cython cells in notbook?

Thank you. That did the trick!

2013-01-14 12:06:40 +0200 received badge  Supporter (source)
2013-01-14 09:47:32 +0200 marked best answer How to use cython functions from other cython cells in notbook?

This works for me:

%cython
from __main__ import test

def test3(int m):
    return test(m)

The function name test is making things more confusing in this case. Python has a module named test, so if you just use import test, the module masks the previously defined function.

2013-01-14 09:47:32 +0200 received badge  Scholar (source)
2013-01-12 17:00:41 +0200 received badge  Nice Question (source)
2013-01-11 18:06:37 +0200 received badge  Student (source)
2013-01-11 18:06:00 +0200 received badge  Editor (source)
2013-01-11 18:02:42 +0200 asked a question How to use cython functions from other cython cells in notbook?

Hi, I'm currently using sage with the notebook interface. How can I define a function in a cython cell and use it in another cython cell?

I understand I need to import the first cython module but the name changes after every evaluation.

Also being able to do this directly from notebook (without writing a separate cython file) and from separate cells would be handy.

For example this works fine:

cell1:

%cython
def test(int n):
    return 2*n

cell 2:

def test2(m):
    return test(m)

cell 3:

test2(3)
5

but this does not:

cell 4:

%cython
def test3(int m):
    return test(m)
pyx:7:15: undeclared name not builtin: test

Thank you :)