On 11/16/13 9:47 AM, Jason Grout wrote:
# this could be much faster if we were evaluating it using vector
arithmetic on a numpy grid, for example.

Here's an example with numpy: http://sagecell.sagemath.org/?q=lifyke

import numpy as np
jitter=0.1 # set to 0 to have a truly uniform grid
opacity=0.5
pointsize=30
numx,numy,numz = 15,15,15

x = np.linspace(-2,2,numx)
y = np.linspace(-2,2,numy)
z = np.linspace(-2,2,numz)

xx,yy,zz = np.meshgrid(x,y,z)
xx += np.random.random(xx.shape)*jitter
yy += np.random.random(yy.shape)*jitter
zz += np.random.random(zz.shape)*jitter

values = xx^2+yy^2+zz^2

# normalize values to be between 0 and 1
values -= values.min()
values /= values.max()

g=[]
for (i,j,k,v) in np.nditer([xx,yy,zz,values]):
g.append(point3d((float(i),float(j),float(k)), size=pointsize, opacity=opacity, color=hue(float(v))))
G = sum(g)

show(G)


--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to