On Sat, Nov 28, 2009 at 3:14 PM, Christopher Olah <christopherolah...@gmail.com> wrote: > Greetings! > > I've implemented a function to export a sage surface as a stl file. > [1] This allows for them to be printed with rep-rap and cupcake (two > open-source 3d printers) using the tool chain: stl file -> skeinforge > -> gcode file -> replicatorg (prints) . (I cant test it because the > printer at hacklab.to is broken right now, but the stl files seem to > work fine in simulations... Otherwise I'd include pretty pictures of > printed plots!) > > There are several reasons I'm writing. Firstly, I wanted to make my > function available to anyone who was interested. In fact, it'd be > great if someone could push it upstream eventually (I understand
I think your function should get included in Sage itself. > there's some kind of review process?). If not, is there a standard way > to store local changes? See "Disseminating Code for Sage" in the Sage Developer's Guide: http://sagemath.org/doc/developer/index.html > > Secondly, I have a strange bug in my code I'm hoping I could get some > suggestions on resolving. At one point, I loop the list provided > face_list(). I run into problems, however, when I pass my function > more complicated plots because face_list() suddenly returns an empty > list. Is this a bug in sage, or am I missing something? I don't know. A concrete example would be helpful. Many thanks for your interest in making Sage and 3d printing work together somehow. > > In the future, I'm planning to implement a function to import stl > files as well. And it may be interesting to just include a wrapper > around skeinforge so that sage can directly export gcode.... > > Help and feedback are appreciated, > > Christopher Olah, hacklab.to > > > [1] > > def surface_to_stl(surface): > out = "solid mathsurface\n" > for i in surface.face_list(): > n = > (i[1][1]*i[2][2]-i[2][1]*i[1][2],i[1][2]*i[2][0]-i[1][0]*i[2][2],i[1][0]*i[2][1]-i[2][0]*i[1][1]) > abs = (n[0]^2+n[1]^2+n[2]^2)^0.5 > n= (n[0]/abs,n[1]/abs,n[2]/abs) > out += " facet normal " + repr(n[0]) + " " + repr(n[1]) + " " > + repr(n[2]) > out += " outer loop\n" > out += " vertex " + repr(i[0][0]) + " " + repr(i[0][1]) + " " > + repr(i[0][2]) + "\n" > out += " vertex " + repr(i[1][0]) + " " + repr(i[1][1]) + " " > + repr(i[1][2]) + "\n" > out += " vertex " + repr(i[2][0]) + " " + repr(i[2][1]) + " " > + repr(i[2][2]) + "\n" > out += " endloop\n" > out += " endfacet\n" > out += "endsolid surface\n" > return out > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel-unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org