[Pybrainsim-activity] SF.net SVN: pybrainsim:[122] trunk/src/Head.py
Status: Planning
Brought to you by:
rgoj
From: <rg...@us...> - 2009-08-18 11:08:04
|
Revision: 122 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=122&view=rev Author: rgoj Date: 2009-08-18 11:07:56 +0000 (Tue, 18 Aug 2009) Log Message: ----------- * Adding the mayavi import * Adding displayHead() method, that currently only shows an example of how to use mayavi (from the mayavi wiki), by displaying an object in 3D. Modified Paths: -------------- trunk/src/Head.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2009-08-18 11:05:08 UTC (rev 121) +++ trunk/src/Head.py 2009-08-18 11:07:56 UTC (rev 122) @@ -15,7 +15,8 @@ # PyBrainSim. If not, see <http://www.gnu.org/licenses/>. from __future__ import division -from numpy import arange +from numpy import pi, sin, cos, mgrid, arange +from enthought.mayavi import mlab __metaclass__ = type # New style classes. Is this necessary? """ @@ -59,6 +60,20 @@ def setHeadModel(self, headModel): self.headModel = headModel + def displayHead(self): + dphi, dtheta = pi/250.0, pi/250.0 + [phi,theta] = mgrid[0:pi+dphi*1.5:dphi,0:2*pi+dtheta*1.5:dtheta] + m0 = 4; m1 = 3; m2 = 2; m3 = 3; m4 = 6; m5 = 2; m6 = 6; m7 = 4; + r = sin(m0*phi)**m1 + cos(m2*phi)**m3 + sin(m4*theta)**m5 + cos(m6*theta)**m7 + x = r*sin(phi)*cos(theta) + y = r*cos(phi) + z = r*sin(phi)*sin(theta) + + # View it. + + s = mlab.mesh(x, y, z) + mlab.show() + def runSimulation(self, duration=1): """Queries all generators, sends the generators' output to connections, to the head model and then to the specified registration sites""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |