Tinkering with Sage today

1 view
Skip to first unread message

photonn

unread,
Jan 11, 2008, 2:52:10 PM1/11/08
to sage-forum
William,

I remember when first tinkering with Sage some months ago, I stumbled
across some example code you did. It was an elliptic curve (37a)
rendered in Tachyon. That image stuck in my mind. It was really a
nice picture. It really was what motivated me to dig further and
start running a sage server.

Well, I started playing with that image today ... just for some
fun ... check out the result.

(sorry for the length)

t = Tachyon(xres=1000, yres=800, camera_center=(2,7,4),
look_at=(2,0,0), raydepth=4)
t.light((8,3,8), 1, (1,1,1))

t.texture('black', ambient=0.6, diffuse=0.3, specular=0.1,
opacity=1.0, color=(0,0,0))
t.texture('red', color=(1,0,0))
t.texture('grey', color=(.9,.9,.9))
t.plane((0,0,0),(0,0,1),'grey')
t.cylinder((0,0,0),(1,0,0),.01,'black')
t.cylinder((0,0,0),(0,1,0),.01,'black')
E = EllipticCurve('37a')
P = E([0,0])
Q = P
n = 100
for i in range(n):
Q = Q + P
c = i/n + .1
t.texture('r%s'%i,color=(float(i/n),0,0))
t.sphere((Q[0], -Q[1], .04), .04, 'r%s'%i)


tx = 2 # translate the letters in the x direction
ty = 1 # translate the letters in the y direction
sc = 0.01 # scale factor, adjust this to make the letters larger or
smaller
rad = 5*sc # radius of cylinders that make the letters of the word
sage
hgt = 2*rad # height of letters off the plane, 1 means bottom of
cylinder touching plane

t.sphere((sc*85+tx,sc*9+ty,hgt),rad,'black') # this group makes the
letter S in sage
t.sphere((sc*32+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*32+tx,sc*49+ty,hgt),rad,'black')
t.sphere((sc*85+tx,sc*49+ty,hgt),rad,'black')
t.sphere((sc*8+tx,sc*83+ty,hgt),rad,'black')
t.sphere((sc*85+tx,sc*83+ty,hgt),rad,'black')
t.fcylinder((sc*85+tx,sc*9+ty,hgt),(sc*32+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*32+tx,sc*9+ty,hgt),
(sc*32+tx,sc*49+ty,hgt),rad,'black')
t.fcylinder((sc*32+tx,sc*49+ty,hgt),
(sc*85+tx,sc*49+ty,hgt),rad,'black')
t.fcylinder((sc*85+tx,sc*49+ty,hgt),
(sc*85+tx,sc*83+ty,hgt),rad,'black')
t.fcylinder((sc*85+tx,sc*83+ty,hgt),
(sc*8+tx,sc*83+ty,hgt),rad,'black')

t.sphere((sc*236+tx,sc*83+ty,hgt),rad,'black') # this group makes the
AG combination
t.sphere((sc*198+tx,sc*83+ty,hgt),rad,'black')
t.sphere((sc*153+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*107+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*107+tx,sc*83+ty,hgt),rad,'black')
t.sphere((sc*160+tx,sc*83+ty,hgt),rad,'black')
t.sphere((sc*203+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*252+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*252+tx,sc*118+ty,hgt),rad,'black')
t.sphere((sc*182+tx,sc*118+ty,hgt),rad,'black')
t.fcylinder((sc*236+tx,sc*83+ty,hgt),
(sc*198+tx,sc*83+ty,hgt),rad,'black')
t.fcylinder((sc*198+tx,sc*83+ty,hgt),
(sc*153+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*153+tx,sc*9+ty,hgt),
(sc*107+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*107+tx,sc*9+ty,hgt),
(sc*107+tx,sc*83+ty,hgt),rad,'black')
t.fcylinder((sc*107+tx,sc*83+ty,hgt),
(sc*160+tx,sc*83+ty,hgt),rad,'black')
t.fcylinder((sc*160+tx,sc*83+ty,hgt),
(sc*203+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*203+tx,sc*9+ty,hgt),
(sc*252+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*252+tx,sc*9+ty,hgt),
(sc*252+tx,sc*118+ty,hgt),rad,'black')
t.fcylinder((sc*252+tx,sc*118+ty,hgt),
(sc*182+tx,sc*118+ty,hgt),rad,'black')

t.sphere((sc*365+tx,sc*83+ty,hgt),rad,'black') # this group makes
the E in sage
t.sphere((sc*273+tx,sc*83+ty,hgt),rad,'black')
t.sphere((sc*273+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*343+tx,sc*9+ty,hgt),rad,'black')
t.sphere((sc*343+tx,sc*49+ty,hgt),rad,'black')
t.sphere((sc*290+tx,sc*49+ty,hgt),rad,'black')
t.fcylinder((sc*365+tx,sc*83+ty,hgt),
(sc*273+tx,sc*83+ty,hgt),rad,'black')
t.fcylinder((sc*273+tx,sc*83+ty,hgt),
(sc*273+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*273+tx,sc*9+ty,hgt),
(sc*343+tx,sc*9+ty,hgt),rad,'black')
t.fcylinder((sc*343+tx,sc*9+ty,hgt),
(sc*343+tx,sc*49+ty,hgt),rad,'black')
t.fcylinder((sc*343+tx,sc*49+ty,hgt),
(sc*290+tx,sc*49+ty,hgt),rad,'black')

t.show() # long time, e.g., 10-20 seconds

William Stein

unread,
Jan 11, 2008, 3:07:49 PM1/11/08
to sage-...@googlegroups.com
Sweet!!

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

sage-tachyon.png

Timothy Clemans

unread,
Jan 11, 2008, 3:08:48 PM1/11/08
to sage-forum
Wow, very impressive (https://sage.math.washington.edu:8909/home/pub/4/
cells/0/sage0.png?1)! You should write some code for making more cool
3d graphics with Sage/Tachyon.

photonn

unread,
Jan 11, 2008, 3:34:25 PM1/11/08
to sage-forum

I did not think of this earlier, but if you would change the
resolution in the first line from 1000 x 800 to 1024 x 768, the result
would be a perfect desktop background. Of course, you could make them
at any resolution by changing those numbers.

My main motivation was to add to the sage marketing material. I think
this version of the logo is really pretty good (the word sage with the
a and g connected, hinting at an infinity symbol).

I just wish the co-ordinate system in Tachyon was right-handed!!! Man
it is tedious to work in a left-handed system.

Timothy Clemans

unread,
Jan 11, 2008, 3:39:44 PM1/11/08
to sage-forum
Could you make the Sage interface to Tachyon have a right handed
coordinate system instead of a left one?

William Stein

unread,
Jan 13, 2008, 1:10:33 AM1/13/08
to sage-...@googlegroups.com
On 1/11/08, Timothy Clemans <timothy...@gmail.com> wrote:
>
> Could you make the Sage interface to Tachyon have a right handed
> coordinate system instead of a left one?

It is much better to use the new 3d graphics, which is right handed
and supports tachyon output. You can see the primitives we
support so far by doing:

sage: import sage.plot.plot3d.all as p
sage: p.
p.arrow3d p.line3d p.plot3d p.tetrahedron
p.cube p.list_plot3d p.plot3d_adaptive
p.dodecahedron p.octahedron p.point3d
p.icosahedron p.parametric_plot3d p.sphere

If you make any 3d plot you can view it using tachyon by
using the viewer='tachyon' option:

sage: P = plot3d(lambda x, y: x^2 + y^2, (-2,2), (-2,2))
sage: P.show(viewer='tachyon', figsize=10)

This does not yet give you the full functionality of tachyon, e.g.,
placement of lights, changing of viewpoint, etc. It would be
nice to have some additional help in implementing 3d primitives...
We made a good start with the above list of commands, but
much remains to be done.

> On Jan 11, 12:34 pm, photonn <wdbr...@gmail.com> wrote:
> > I did not think of this earlier, but if you would change the
> > resolution in the first line from 1000 x 800 to 1024 x 768, the result
> > would be a perfect desktop background. Of course, you could make them
> > at any resolution by changing those numbers.
> >
> > My main motivation was to add to the sage marketing material. I think
> > this version of the logo is really pretty good (the word sage with the
> > a and g connected, hinting at an infinity symbol).
> >
> > I just wish the co-ordinate system in Tachyon was right-handed!!! Man
> > it is tedious to work in a left-handed system.
> >
>

photonn

unread,
Jan 14, 2008, 5:20:30 PM1/14/08
to sage-forum
William,

In this particular case, having control over the camera and lights was
key in getting a decent looking image. The process was much like
photography. I fiddled with the lights for a good half hour to get
what I was looking for. My goal, in the end, was to create some
reasonably professional-looking marketing material.

I will look into the new method once I upgrade my sage installation.
I am still on 2.8.15 :) and I might not upgrade until 2.10.x

On Jan 13, 12:10 am, "William Stein" <wst...@gmail.com> wrote:

William Stein

unread,
Jan 14, 2008, 7:26:30 PM1/14/08
to sage-...@googlegroups.com
On Jan 14, 2008 2:20 PM, photonn <wdb...@gmail.com> wrote:
>
> William,
>
> In this particular case, having control over the camera and lights was
> key in getting a decent looking image. The process was much like
> photography. I fiddled with the lights for a good half hour to get
> what I was looking for. My goal, in the end, was to create some
> reasonably professional-looking marketing material.

You succeeded. The current 3d code I was talking about doesn't
help at all *yet* with lights, unfortunately. However it should in
the future.

> I will look into the new method once I upgrade my sage installation.
> I am still on 2.8.15 :) and I might not upgrade until 2.10.x
>

Reply all
Reply to author
Forward
0 new messages