crash course (was 5 days)

25 views
Skip to first unread message

kirby urner

unread,
Apr 3, 2016, 12:05:16 PM4/3/16
to mathf...@googlegroups.com

I'm continuing the thread of a five day cram, as a mental exercise.

Peter was suggesting a "three chord" approach to making recombinant "math music".  I was mixing in memes I consider critical from a "code school" world:  SQL and making web pages.

Digging into my past efforts, I'm dredging up the following:

Show using SQL to define related tables that contain information about:

Polyhedrons:  name, overall characteristics
Faces:  polygons that make up each polyhedron
Vertexes (vertices):  the corners, with spatial coordinates

For example, the first table might be:

TETRA | 4 | 4 | 6 | 1
CUBE | 8 | 6 | 12 | 3
OCTA | 6 | 8 | 12 | 4 
RD | 12 | 14 | 24 | 6
CUBOCTA | 12 | 14 | 24 | 20 
ICOSA | 12 | 20 | 30 | rt2(2) * 5 * phi**2
PD | 20 | 12 | 30 | (phi**2 + 1) * 3 * rt2(2)
RT | 30 | 32 | 60 | 15 * rt2(2)

What are those numbers?  Vertexes, Faces, Edges, volume.

So first we'd need to create the table, then import then import the above.

The Faces table would look something like:

TETRA | (A,B,C)
TETRA | (A,C,D)
TETRA | (A,D,B)
TETRA | (B,C,D)

and them the Vertexes table needs to give each letter-named point its coordinates e.g.

A | 1 | 0 | 0 | 0
B | 0 | 1 | 0 | 0
C | 0 | 0 | 1 | 0
D | 0 | 0 | 0 | 1

and so on with the named vertexes.

A couple things will seem strange to the veteran math teacher here: 

(1) the volumes column assigning 1 to the tetrahedron and 3 to the cube suggests familiar ratios but an unusual unit

(2)  the coordinates appear unfamiliar and why are there four of them given XYZ takes only three.

These wrinkles might be removed by another instructor while keeping the overall structure of the three tables. 

I'm using the Martian Math approach which spans space with four basis vectors from the origin to the corners of a regular tetrahedron of edges two (2R or 1D) and volume one.  R = radius of unit sphere i.e. four packed tightly together define the beginning point for our four vectors.

XYZ of course uses three basis vectors plus their three negatives to span volume, creating the familiar six-spoke "jack" at the origin. 

Quadrays, in contrast, create a "caltop" of four basis vectors with no negatives required.

http://www.reddogforge.co.uk/images/caltrop.jpg
http://www.hbjzds.com/344918-jacks.html

XYZ divides space into eight octants, whereas Quadrays divide space into four quadrants.  -(1,0,0,0) = (0,1,1,1).  We get the inverse dual tetrahedron by flipping the 1s to 0 and 0s to 1.  Regular tip-to-tail vector addition is used to map any point in space.

Why do something so off-beat and esoteric though?  Many teachers might agree that the SQL table beginning is a good one, but why those unfamiliar volume numbers and odd coordinate system?

Partly that's to level the playing field so that students who already know this material maybe have something new to think about.

A goal is to start from this tabular information and actually render the polyhedrons as 4D objects (or 3D as we say in the XYZ namespace).  Conversion to XYZ will be necessary as that's how our rendering libraries expect their input.

Finally, we'll want to return these images back in the form of web pages.

We have five days in which to do it all.  Don't worry though, as a lot of scaffolding is provided.  I'm not one to teach programming by starting with a blank canvas.  Reading and modifying existing code is a first step.  Blank canvas coding comes later.

Kirby


Kirby


kirby urner

unread,
Apr 3, 2016, 1:21:47 PM4/3/16
to mathf...@googlegroups.com


On Sun, Apr 3, 2016 at 9:05 AM, kirby urner <kirby...@gmail.com> wrote:

<< SNIP >>
 
For example, the first table might be:

TETRA | 4 | 4 | 6 | 1
CUBE | 8 | 6 | 12 | 3
OCTA | 6 | 8 | 12 | 4 

Notice that duals swap V and F, but keep E (edges). 

We could add the dual (inverse) tetra but it would look the same:

INV_TETRA | 4 | 4 | 6 | 1

but then:  TETRA + INV_TETRA = CUBE (where + is a kind of juxtaposition and connecting of dots).

Put another way:  TETRA + dual(TETRA) = CUBE  (defining dual such that edges criss-cross)

CUBE + dual(CUBE) = RD  (space-filling rhombic dodecahedron, voronoi cell for CCP)

dual(RD) = Cubocta (12 unit-spheres around 1).

Once we have these shapes in play, we have some new operations to consider:

(A) scaling (grow and shrink while staying in a fixed position, e.g. center = (0,0,0,0)
(B) rotation (introduces axes of spin, through opposite faces, edge centers, vertexes)
(C) translation (moving the shapes relative to one another)

We how have the basis for animation (transformation, morphing etc.).  I'm reconnecting with my third chord here, the introduction of time and change i.e. energetic existence (as opposed to static blueprints).

The Object Oriented Paradigm (OOP) enters in here, in that Polyhedron is a generic shape class, subclass into the various examples (e.g. TETRA) and then these latter subclasses become "instances" into specific shapes in a "landscape" complete with additional attributes such as texture / color / reflectivity and so on.

By Day 2, really even by Day 1, we're in the realm of computer graphics.

I want a lot of graphical not just lexical stuff in my 5 day crash course. 

In conventional high school algebra, that means going from algebraic functions to plotting, converging algebra with XY coordinate geometry.  I'm operating somewhat differently, plotting shapes in volume, not curves on a plane.  We don't have to start with "the flat stuff".

Shapes in landscapes, volumetric, are way more familiar and experiential that purely planar stuff. 

What comes first, the sandy beach and the ocean, or just the sandy beach, filling the screen and used to show plane figures?  The latter is an abstraction / generalization based on the former experiential setting.

My "plane figure" cartoons, for when we do some plane geometry, may well use a "sandy beach" look i.e. the triangle A, B, C appears as thin lines in the sand, as if drawn with a stick.  This is our taut string and scribe tool kit. 

Plant one end of the string at the origin and pull the string taught. 

Draw a circle.  Now take the radius and use that length to "cut" the circle going around.  You'll get the six chords of a hexagon.  There is no "little bit left over" as we're not doing radians, we're doing chords.

http://amsi.org.au/teacher_modules/A8/A8g36.png
http://etc.usf.edu/clipart/43400/43447/6c2_43447_lg.gif

Now tile the plane (beach) with hexagons.  Now zoom back, and we see the hexagons are on the beach, on a planet, on a sphere. 

https://nonlinearnarratives.files.wordpress.com/2011/02/civilizationv.jpg  (from Civilization)

Plane geometry is actually zoomed-in spherical geometry.  Heresy, I know.  Or call it non-Euclidean (no "infinite planes" need apply).

Kirby

(a primer for the 5 day course -- students get the Kindle version and get to keep it)




kirby urner

unread,
Apr 4, 2016, 3:52:29 AM4/4/16
to mathf...@googlegroups.com
Here's a short program to be included in the 5-day crash course.  Quite a bit of the
course is used to practice programming.  SQL and HTML are basic to STEM as the
former is about keeping data well-organized in tabular form, and the latter is about
viewing it in a web browser.

This material is geared for 10th graders and above who have already looked at
some spatial geometry and understand about XYZ coordinates and might be ready
for, or are already familiar with, the "vector" concept.

This material is also appropriate for adults in code school looking for a new career
involving coding, and draws in their prior experience with high school level math
and history.

=========
# -*- coding: utf-8 -*-
"""
Created on Sun Apr  3 14:09:02 2016

@author: Kirby Urner (c) MIT License

From SQL to HTML with geometry in the middle.  Developed
for a five day crash course in STEM-relevant mathematics
which includes learning a computer language, in this case
Python.

The script store row data about a few polyhedra in a table,
using SQL to create the table and insert the rows. Then
two of the columns are selected to build an HTML page
containing a volumes table.

Expressions involving phi, the golden ratio, are evaluated
to give floating point values for volumes in some cases. 
Other volumes are simply integers.

The volumes are expressed in less familiar 'tetravolume'
units as developed in Buckminster Fuller's writings, and
in subsequent follow-on investigations by students of
Fuller's approach, such as David Koski.

Interesting discussion and further topics for investigation
derive from using this somewhat alien system of mensuration,
wherein a regular tetrahedron of edges L has the volume
L * L * L or L to the 3rd power.
"""

import sqlite3 as sql               # SQL library included in Python
from collections import namedtuple  # used for row data
from math import sqrt as rt2        # rename sqrt to rt2

phi = (1 + rt2(5))/2                # could use the Greek letter

# information about polyhedrons, could be a file
data = """\

TETRA | 4 | 4 | 6 | 1
CUBE | 8 | 6 | 12 | 3
OCTA | 6 | 8 | 12 | 4
RD | 12 | 14 | 24 | 6
CUBOCTA | 12 | 14 | 24 | 20
ICOSA | 12 | 20 | 30 | rt2(2) * 5 * phi**2
PD | 20 | 12 | 30 | (phi**2 + 1) * 3 * rt2(2)
RT | 30 | 32 | 60 | 15 * rt2(2)"""

# create the SQL table in memory for this script
conn = sql.connect(":memory:")
curs = conn.cursor()

# here's the table
curs.execute(
"""create table shapes (
name text,
V integer,
F integer,
E integer,
vol float)""")

Rec = namedtuple('Rec', 'name V F E vol') # e.g. Rec.

shapes = [ ]
for shape in data.split("\n"):
    rec = shape.split("|")
    table_row = Rec(rec[0].strip(), # name
                  int(rec[1]),      # V
                  int(rec[2]),      # F
                  int(rec[3]),      # E
                  float(eval(rec[4]))) # volume
    print(table_row)
   
    # for adding rows to the table
    to_do = """insert into shapes (name, V, F, E, vol)
    VALUES ('{}', {}, {}, {}, {})""".format(
    table_row.name,  # substitutes into insert command
    table_row.V,
    table_row.F,
    table_row.E,
    table_row.vol)
   
    curs.execute(to_do)

conn.commit()

# this is the skeleton of a web page, into which row data is inserted
output = """\
<!DOCTYPE html>
<html>
<head>
<title>Volumes Table</title>
</head>
<body>
<table>
{}
</table>
</body>
</html>
"""

# get the row data back out from the table...
curs.execute("""select name, vol from shapes order by vol""")

table_data = ""  # starts empty
for name, vol in curs.fetchall():
    table_data += """<tr><td>{}</td><td>{}</td></tr>\n""".format(name, vol)

conn.close()

# save the html file, view in browser
fh = open("shapes.html", "w")
output = output.format(table_data)
print(output)
print(output, file = fh)
fh.close()


The resulting web page looks like this:

TETRA1.0 CUBE3.0 OCTA4.0 RD6.0 PD15.350018208050782 ICOSA18.512295868219162 CUBOCTA20.0 RT21.213203435596427

kirby urner

unread,
Apr 5, 2016, 10:39:42 PM4/5/16
to mathf...@googlegroups.com

A next step is to introduce HTML5.  Check this out:

http://dmccooey.com/polyhedra/Cuboctahedron.html

Here's the file behind it, which follows the expected form:  faces matched to vertexes.  Here the data is in a plain old text file but in our crash course it'll be in SHAPES.DB or something similar.  Plus I might use Quadrays:

https://en.wikipedia.org/wiki/Quadray_coordinates

Cuboctahedron

C0 = 0.7071067811865475244008443621048 = sqrt(2) / 2

V0  = ( C0, 0.0,  C0)
V1  = ( C0, 0.0, -C0)
V2  = (-C0, 0.0,  C0)
V3  = (-C0, 0.0, -C0)
V4  = ( C0,  C0, 0.0)
V5  = ( C0, -C0, 0.0)
V6  = (-C0,  C0, 0.0)
V7  = (-C0, -C0, 0.0)
V8  = (0.0,  C0,  C0)
V9  = (0.0,  C0, -C0)
V10 = (0.0, -C0,  C0)
V11 = (0.0, -C0, -C0)

Faces:
{  0,  5,  1,  4 }
{  0,  8,  2, 10 }
{  7,  2,  6,  3 }
{  7, 11,  5, 10 }
{  9,  1, 11,  3 }
{  9,  6,  8,  4 }
{  0,  4,  8 }
{  1,  5, 11 }
{  2,  7, 10 }
{  3,  6,  9 }
{  4,  1,  9 }
{  5,  0, 10 }
{  6,  2,  8 }
{  7,  3, 11 }


Kirby



Fixing:
Reply all
Reply to author
Forward
0 new messages