[Edu-sig] Integrated Studies (long)

kirby urner kirby.urner at gmail.com
Wed Sep 10 00:05:07 CEST 2008


Teacher Notes:

On Tue, Sep 9, 2008 at 12:12 PM, kirby urner <kirby.urner at gmail.com> wrote:

<< SNIP >>

> For example, a Tetrahedron ABCD has facets [(A,B,C), (A,C,D), (A,D,B),
> (B,C,D)].  Ordering matters within a facet (we're hopping around a
> face, like a fenced yard with fence posts), so the Facets table has a
> vertex_id column to keep them in order, within facet_id.  You'll find
> an ORDER BY vertex_id in the source code below.

If you're doing the Oregon Curriculum group theory segments, then
you'll recognize a link here to "cyclic notation", a way to encode
permutations, e.g. letters A-Z to some other sort thereof.  Many
textbooks use numbers.

So like if I write ((1, 4, 3), (2)), that means 1 -> 4, 2 -> 2, 3 ->
1, 4 -> 3 where -> is an "ascii arrow" meaning "maps to".

The J language has a primitive verb for doing cyclic notation:

http://jsoftware.com/help/dictionary/dccapdot.htm

> You'll see a list comprehension in getedges that does precisely this.
> f[1:]+[f[0]] is the syntax for turning a list into a rotated version
> of itself i.e. if f = [A, B, C] then the result is [B, C, A] (see
> below).

This is where exercises with "little lambda" might be fun, Python's
light-weight "anonymous function", a tip of the hat to the LISP &
Scheme family, which make lambda an animal worthy of worship, i.e. a
much bigger deal (but then we have snakes to be proud of).

>>> func = lambda thelist: thelist[1:] + [thelist[0]]
>>>
>>> func(['A','B','C','D'])
['B', 'C', 'D', 'A']

Of course naming it func somewhat defeats the whole purpose of keeping
it anonymous, not that lambda isn't itself a name, for a greek letter.

>
> The idea here is enterprising GnuMath teachers using this as tweakable
> scaffolding.
>
> Even a beginning student can start changing the color, reloading the
> module, and redrawing a polyhedron, all interactively via the shell
> (remember to restart after closing the VPython window, automatic in
> IDLE, but not in Wing 101, which I'm currently using).

VPython lets you build colors with RGB values, so this would be a good
time for a segment on that, if students seem clueless.

But you've also got the built-in colors to start, so if really
beginners, maybe don't bore them with yet more details before letting
them dive in, getting their hands "dirty".  You could also assign each
Polyhedron a default color in the master table, or a separate face,
vertex and edge color.  Go wild.

>>> from visual import color
>>> dir ( color )
['__builtins__', '__doc__', '__file__', '__name__', 'black', 'blue',
'colorsys', 'cyan', 'green', 'hsv_to_rgb', 'magenta', 'orange', 'red',
'rgb_to_hsv', 'white', 'yellow']

You'd think someone would add to this list in the original package, or
maybe I just have an old version.  I agree with Arthur that VPython is
an important asset, an inspiration for future packages and/or newer
versions of itself.

Note that in Python 3.0 we have to unpack reload from the imp "suitcase":

>>> from imp import reload

But as of this writing in late 2008, there wasn't a pysqlite driver
for Python 3.0.

>>> import sqlpolys
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import sqlpolys
  File "/home/kirby/sqlpolys.py", line 1, in <module>
    from pysqlite2 import dbapi2 as sqlite
ImportError: No module named pysqlite2

However, there was APSW (Another Python Sqlite Wrapper) that did have
3.0 capability:
http://code.google.com/p/apsw/

> There's a lot going on here, i.e. this is a dense packing of a lot of
> ideas, meaning student should find it rewarding and relevant, plus the
> eye candy is pretty fun (even better with enhancements).
>
> Kirby

If you get through all this and they're hungry for more, consider
using a string.Template approach to building a POV-Ray file, start
adding facets as polygons, do more with vertices etc.

You'll find lots in the Oregon Curriculum to help you down this road,
if that's the road you choose.

http://www.4dsolutions.net/ocn/cp4e.html

Or reimplement in APSW as an exercise?

Kirby


More information about the Edu-sig mailing list