Skip to main content

Posts

Showing posts from October, 2007

Beamer on MikTeX

Need xcolor and pgf for the new beamer to run. MikTeX kept failing on pgf install. Led to discovery of problem with MikTeX 2.6 and LZMA compressed package archive files . Had to update just the miktex-bin, then update the rest to get the latest package manager. Remember, don't have package manager and updater running at the same time - they access some same files and can lock each other out on windows.

MikTeX on vista

MikTeX works fine on vista, except on occasion if I don't run package manager as root I get a com surrogate error. I just start package manager as root (run as administrator) to get around this problem.

Odd error with mlab and lighting - TVTK

Is there a time delay to the lighting manager being instantiated when a figure is set up? In ipython the following lines work fine fig = mlab.figure(browser=False) fig.renwin.light_manager.lights[0].move_to(0,-45) But this doesn't fig = mlab.figure(browser=False);fig.renwin.light_manager.lights[0].move_to(0,-45) In the noninteractive mode (i.e. running a script as opposed to typing in commands in the shell) even the first version does not work. I tried inserting a delay (time.sleep()) but that does not help l = light_manager.CameraLight(fig.renwin) l.move_to(0,-45)

Figure properties - TVTK

fig.renwin.off_screen_rendering = True #allows you to minimize the window and keep drawing/saving to file Lighting fig.renwin.light_manager .lights .light_mode = 'vtk' or 'raymond' .lights[0].move_to(0,-45) light[0] seems to be the important one. azimuth , elevation, with 0 elevation being right over head The rendering properties (size etc.) are controlled from fig.renwin.render_window .aa_frames = .size = array([width, height]) OR .set_size(width, height) fig.renwin.show_axes = True #turns on the little axis orientation indicator

Some important properties - TVTK

(For how to access object properties see this post ) ... fig = mlab.figure(browser = False) ... s = mlab.Surf(x,y,z) ... s.actors[0].property. .representation = 'w' wireframe 's' surface .opacity = 0...1 .interpolation = 'flat' 'gouraud' 'phong' .ambient = 0...1 #uniform (direction independent) lighting on surface .color = [r,g,b] .specular = 0...1 .specular_color = [r,g,b] .specular_power =0...1

view manipulation - TVTK

You have to manipulate the camera which is a enthought.​ pyface .​ tvtk .​ decorated_scene .​ DecoratedScene object if fig is a figure window handle returned from mlab.figure() fig.renwin.camera.position fig.renwin.camera.window_center fig.renwin.camera.azimuth(..) rotate scene by .. degrees fig.renwin.camera.elevation(..) rotate scene by .. degrees fig.renwin.camera.zoom(..) zoom in/out fig.renwin.reset_zoom() fig.renwin.isometric_view() remember to call fig.renwin.render() to see the changes

Setting surface rendering properties - TVTK

From a hint here import scipy x = scipy.arange(-7., 7.05, 0.1) y = scipy.arange(-5., 5.05, 0.1) [X,Y] = scipy.meshgrid(x,y) Z = 3.0*scipy.sin(X*Y+1e-4)/(X*Y+1e-4) from enthought.tvtk.tools import mlab fig = mlab.figure(browser = False) s = mlab.Surf(X, Y, Z) fig.add(s) act = fig.objects[1].actors[0] #object[1] is the surface, it has one actor, which turns out to be a surface act.property.representation = 'w' #make it a wireframe act.property.representation = 's' #turn it back to a surface!

Getting mlab/ivtk/mayavi to work

Download and run Enthought Enstaller . It pulls of various things from Enthought's website and installs them in the site-pacages etc. Crucially it will put enstaller.exe under \python25\Scripts Run enstaller.exe In the GUI tab to repositories and check Mavavi, VTK, enthought.traits, enthought.tvtk, wxPython click install packages change ipython to run with wthread commandline option (ipython -wthread) follow any number of examples from the cookbook for mlab eg: from enthought.tvtk.tools import mlab fig = mlab.figure(browser = False) mlab.test_surf(fig) #a built in test function for a nice looking surface t = mlab.Title()#add a title object t.text = 'Ha' fig.add(t) fig.pop() #remove the last added object (in this case the title) fig.renwin.camera.window_center = fig.renwin.save('tada.png') #save the figure to png Useful links:

Memory leaks in matplotlib

On windows, with Python 2.5 matplotlib has a memory problem using the default tk backend. Say I have to generate 100 figures in succession, dumping each to a file because I want to create and animation from them. Using tk the memory consumption just keeps increasing. The trick is to use the agg backend for such tasks (see this post ). The agg backend does not have this memory leak.

Archery at UMD

At the range today I ran into two fellas from the University of Maryland who are taking the initiative to start a Archery club at the university. About time ! Information about the group can be found at http://stars.umd.edu/dsp_description.asp?id=17101&sem=181

A note on the bow stringer

The bow stringer I have came with instructions to step on the string with both feet about shoulder width apart. I didn't understand why, especially since some instructions elsewhere (and here ) say to stand on the string with one foot. Today I think I figured out why, at least with my bowstringer. The cup, which covers the upper tip, into which you are trying to slide the bowstring, has a tendency to cover the tip more and more closely, eventually pinching off the notch in the tip into which you need to slide the bowstring. By standing with your feet apart, you cause the tension in the string to act more perpendicularly to the limb, and so the cup is less likely to slide inwards and cover the notch. If you stand with only one foot on the stringer, or with feet close together, the string makes a shallow angle with the limb. This pulls the cup more tightly onto the tip, sliding it over the notch. An additional benefit is that you are causing less tension in the bowstringer. (Note th...

Ditching blender for Alibre free edition

Ok, either I am doing something wrong or Blender really has a problem with stl export. When I export my models to stl I can load the models just fine in Myriad 3D viewer , but when I load them in Zcorp's Zprint the normals are wrong and they show up as wire frames and not solid models. Hyunyoung from the fab-lab suggested I try out Alibre Design Xpress , which is a free version of their CAD software. I got it to work with minimum hassle. The only thing I could not figure out how to do was sketch elipses! I needed the latest JVM