I wrote this, along with other 3d hacks for Alex's plotting code, about 9 
months ago.  It's so horrendously slow, I didn't show it off much.  You can 
imagine my surprise that the resultant image is the only image in Wikipedia's 
SAGE article to this day.


def xproj(x,y,z,r):
   return (y*r[1] - x*r[3])*r[2]
def yproj(x,y,z,r):
   return z*r[2] - (x*r[1] + y*r[2])*r[0]
def rotation_list(tilt,turn):
     return [ sin(tilt*pi/180),
             sin(turn*pi/180),
             cos(tilt*pi/180),
             cos(turn*pi/180) ]

def polygon_3d(points, tilt=30, turn=30, **kwargs):
     rot = rotation_list(tilt,turn)
     points2 = [(xproj(x,y,z,rot), yproj(x,y,z,rot)) for (x,y,z) in points ]
     return polygon(points2, **kwargs)

def testplot(func,xlist,ylist,colorf):
   p = Graphics()

   for n in range(len(xlist)-1):
     i = xlist[n]
     i1= xlist[n+1]
     for m in range(len(ylist)-1):
       j = ylist[m]
       j1 = ylist[m+1]
       f = func(i,j)
       fj= func(i1,j)
       fi= func(i,j1)
       f2= func(i1,j1)
       c = colorf(i,j,f)
       c2= colorf(i1,j1,f2)
       p+= polygon_3d( [(i , f  , j ),
                        (i1, fj , j ),
                        (i , fi , j1)],
                       rgbcolor = c)
       p+= polygon_3d( [(i1, f2, j1 ),
                        (i1, fj , j ),
                        (i , fi , j1)],
                       rgbcolor = c2)


   return p

def f(x,y):
   return cos(sqrt(x^2 + y^2))
def c(x,y,z):
   return (abs(z),0,abs(sin(sqrt(x^2+y^2))))

testplot(f,srange(-5,5,.1),srange(-5,5,.1),colorf=c).show(axes=False)




On Thu, 24 May 2007, David Joyner wrote:

>
> On 5/23/07, William Stein <[EMAIL PROTECTED]> wrote:
>>
>> On 5/23/07, Marshall Hampton <[EMAIL PROTECTED]> wrote:
>>> Surface plots are very important for my sage-teaching plans.
>>> Currently the maxima surface plots don't work for a notebook running
>>> on a different machine (unless there is some way of piping that over
>>> - ?).
>>
>> Currently unfortunately there is no good support for surface plots in the
>> SAGE notebook.  This is a major major gap in SAGE, which hasn't been
>> remedied yet.  It is possible to draw nice surface plots in the notebok
>> via Tachyon but this is not very good yet.  Some of the SAGE developers
>> last year wrote a lot of code necessary for surface plotting, but we
>> still don't have a good rendering system.
>
> I'm not sure what "good rendering" means. Can (for example) a
> square in 3-space with a specified size, position and
> orientation be plotted? If so, what is the command?
>
>
>>
>> NOTE: If you can figure out how to tell maxima to save a plot to a file
>> instead of displaying it, then it will get displayed by the notebook.  The
>> notebook has the cool property that it simply automatically displays any
>> .png images that get created as a side-effect of running a command.
>> They have to get created in the working directory of the notebook cell
>> though, and maxima might place the file elsewhere.  Anyway, if somebody
>> were to post maxima code that shows how create a graph and save it
>> to a file, then it would probably be easy for me to figure out how to make
>> that plot appear in the notebook.
>
> This can be done using gnuplot (which does not come with SAGE).
> I sent an email to the maxima email list and it seems that openmath (which
> does come with SAGE) cannot save to a file using a plot option.
> Openmath does have the ability save to a ps file, but apparently only
> using the mouse.
>
>
>>
>> William
>>
>>>
>>
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to