## Tuesday, August 21, 2007

### Final SoC Report

I've written a final SoC report and posted it in the SymPy wiki. Click here to read it. You will also find similar documents from other SymPy SoC participants here.

## Saturday, August 18, 2007

### VIDEO: Key Bank Tower Implosion (Downtown Salt Lake City, UT)

This is the video I shot of the Key Bank Tower controlled demolition/implosion in downtown Salt Lake City, UT, earlier this morning. We were standing on the East side of the parking lot across the street from the Triad center and the unfortunately re-branded Energy Solutions Arena (formerly the Delta Center). Digg It.

Update: Full HD-res H.264 version.

Update: Full HD-res H.264 version.

## Thursday, August 9, 2007

### SymPy Plotting: Custom Colors Tutorial

One of the most-requested features for SymPy plotting has been the ability to use custom color schemes. I've now implemented this with the syntax described in this post. The upshot is that you can now use any color scheme expressible as a function of x, y, z, u, and/or v. I'll give some concrete examples to get you started, and then you can do something cool with it. We'll start by setting up a plot:

Now let's plot a saddle and color it by the magnitude of its gradient:

Remember that the algorithm for coloring works like this:

Next, let's try a color gradient with four steps:

The other way to specify a color scheme is to give a separate function for each component r, g, b. With this syntax, the default color scheme is defined:

This maps z->red, y->green, and x->blue. In some cases, you might prefer to use the following alternative syntax:

You can still use multi-step gradients with three-function color schemes. When somebody uses this to visualize something useful like curvature, I'd really like to hear about it.

>>> from sympy import symbols, Plot

>>> x,y,z,u,v = symbols('xyzuv')

>>> p = Plot(axes='none')

>>> from sympy import symbols, Plot

>>> x,y,z,u,v = symbols('xyzuv')

>>> p = Plot(axes='none')

Now let's plot a saddle and color it by the magnitude of its gradient:

>>> fz = x**2-y**2

>>> Fx, Fy, Fz = fz.diff(x), fz.diff(y), 0

>>> p[1] = fz, 'style=solid'

>>> p[1].color = (Fx**2 + Fy**2 + Fz**2)**(0.5)

>>> fz = x**2-y**2

>>> Fx, Fy, Fz = fz.diff(x), fz.diff(y), 0

>>> p[1] = fz, 'style=solid'

>>> p[1].color = (Fx**2 + Fy**2 + Fz**2)**(0.5)

Remember that the algorithm for coloring works like this:

- Evaluate the color function(s) across the curve or surface.
- Find the minimum and maximum value of each component.
- Scale each component to the color gradient.

>>> p[1].color = (Fx**2 + Fy**2 + Fz**2)**(0.5),

................ (0.1,0.1,0.9), (0.9,0.1,0.1)

>>> p[1].color = (Fx**2 + Fy**2 + Fz**2)**(0.5),

................ (0.1,0.1,0.9), (0.9,0.1,0.1)

Next, let's try a color gradient with four steps:

>>> gradient = [ 0.0, (0.1,0.1,0.9), 0.3, (0.1,0.9,0.1),

................ 0.7, (0.9,0.9,0.1), 1.0, (1.0,0.0,0.0) ]

>>> p[1].color = (Fx**2 + Fy**2 + Fz**2)**(0.5), gradient

>>> gradient = [ 0.0, (0.1,0.1,0.9), 0.3, (0.1,0.9,0.1),

................ 0.7, (0.9,0.9,0.1), 1.0, (1.0,0.0,0.0) ]

>>> p[1].color = (Fx**2 + Fy**2 + Fz**2)**(0.5), gradient

The other way to specify a color scheme is to give a separate function for each component r, g, b. With this syntax, the default color scheme is defined:

>>> p[1].color = z,y,x, (0.4,0.4,0.4), (0.9,0.9,0.9)

>>> p[1].color = z,y,x, (0.4,0.4,0.4), (0.9,0.9,0.9)

This maps z->red, y->green, and x->blue. In some cases, you might prefer to use the following alternative syntax:

>>> p[1].color = z,(0.4,0.9), y,(0.4,0.9), x,(0.4,0.9)

>>> p[1].color = z,(0.4,0.9), y,(0.4,0.9), x,(0.4,0.9)

You can still use multi-step gradients with three-function color schemes. When somebody uses this to visualize something useful like curvature, I'd really like to hear about it.

## Saturday, August 4, 2007

### New Plotting Examples

Try running examples/plotting.py in an interactive shell:

Other updates:

Other updates:

- New experimental option 'use_lambda', which speeds up calculation by an order of magnitude (used in most of the examples, but doesn't work in every case yet).
- Custom coloring can be applied in real-time:
`>>> p[1].color = 0.3,0.3,0.9 # any solid color`

>>> p[1].color = 'z,y,x' # lambda-based (fast)

>>> p[1].color = x,y,z # sympy expr of x,y,z

>>> p[1].color = u,v,u*v, (u,v) # or of parameters - Style property:
`>>> p[1].style = 'wireframe'`

>>> p[1].style = 'solid'

>>> p[1].style = 'both' - Natural right-click translation in the plane of the screen.
- Middle-click drag zoom.
- Progress percentage displayed in window caption for long calculations.
- z,c and numpad 1,3 rotate about the z axis regardless of camera angle.
- x and numpad 5 reset view.

Subscribe to:
Posts (Atom)