37
Algo Geom / NCTM 08 Reno Algorithmic Geometry Pierre Bierre AlgoGeom.org Pleasanton CA NCTM 2008 Reno NV copyright Spatial Thoughtware 2008

Algo Geom / NCTM 08 Reno Algorithmic Geometry Pierre Bierre AlgoGeom.org Pleasanton CA NCTM 2008 Reno NV copyright Spatial Thoughtware 2008

Embed Size (px)

Citation preview

Algo Geom / NCTM 08 Reno

Algorithmic Geometry

Pierre Bierre

AlgoGeom.orgPleasanton CA

NCTM 2008 Reno NV

copyright Spatial Thoughtware 2008

Algo Geom / NCTM 08 Reno

What is Algorithmic Geometry??

MATHEMATICS COMPUTER SCIENCE

Advanced geometry problem-solving

paper & pencil sketching Java programming

vector features interactive graphics

SCIENCE ENGINEERING

new formal concepts automate your math know-how

Algo Geom / NCTM 08 Reno

Pierre Bierre

BS Theoretical Physics MS Computer Science Neuropsychology

motion picture artificial intelligence immunology

data analysis

robotics2003: algorithmic geometry crystallized

2004 book: Flexing the Power of Algorithmic Geometry

2005: pilot course (proof-of-concept)

Algo Geom / NCTM 08 Reno

Today’s outline

Core 2D representations

Getting started with Java 2D graphics

Group exercise: problem from week 6

Lab problem exercises

Core 3D representations

3D graphics workspace

How can I get involved?

2D

3DResults from 2005 pilot

Algo Geom / NCTM 08 Reno

Getting started with Java…

Algo Geom / NCTM 08 Reno

Core 2D mathematical representations

Algo Geom / NCTM 08 Reno

How to represent 2D direction?

unitcircle

[ 1 1 ]

[ -1 -1 ]

y

x

In the computer,

is just a number

/4

.785397.06858-5.49778…

0 <= < 2

0.0000016.283184

discontinuity at 2 !

not a 1:1 representation!

A single real number doesn’t have the information capacity to do the job

Algo Geom / NCTM 08 Reno

How to represent 2D direction?

unitcircle

[ 1 1 ]

[ -1 -1 ]

y

x

d1[ .707 .707 ]

[ .894 -.447 ]d2

Algo Geom / NCTM 08 Reno

How to represent 2D direction?

y

x

unitcircle

d1

d2

[ 1 1 ]

[ -1 -1 ]

[ .707 .707 ]

[ .894 -.447 ]

direction vector

unit vector used to represent spatial direction

Advantages (computational and mental):

1:1 representation continuity extends naturally to 3D

[ .708, .706 ]

Algo Geom / NCTM 08 Reno

How do you compute direction vectors?y

x2

[ 1 1 ]

[ 2 -1 ]

unitcircle

d1

d2

d2 = [ 2 -1 ]norm = = [ .894 -.447 ]

d1 = [ 1 1 ]norm = len ([ 1 1 ]) sqrt ( 12 + 12 )

= = [ .707 .707 ][ 1 1 ]

1.414=

[ 2 -1 ]

len ([ 2 -1 ]) sqrt ( 22 + -12 )=

2.236=

[ 2 -1 ]

[ 1 1 ] [ 1 1 ]

[ 2 -1 ]

from points!

Algo Geom / NCTM 08 Reno

You can compute direction from p1 to p2…

d

y

x

p1

p2

d = normalize (p2 – p1)

Algo Geom / NCTM 08 Reno

Line “hit-testing” problem….

Algo Geom / NCTM 08 Reno

How to represent infinite 2D lines?

y

x

L

p • o ==

l

What is invariant (numerically) about all points on line L?

l

l = signed distance from origin

o

o = orientation (direction perpendicular to line)

y = mx + b

(m = dy/dx)

fails for vertical lines!

[ o l ] representation of 2D line

algos must handle all cases

Algo Geom / NCTM 08 Reno

How to do coordinate rotation?

(without angles)

Algo Geom / NCTM 08 Reno

Coordinate rotation…

x

y

newYaxisp1

newXaxis

What are new coordinates of p1 if axes are rotated as shown?

Instead of angle , just say the newXaxis direction you want to use

Algo Geom / NCTM 08 Reno

Learn how to visualize dot product of two vectors

y

xd

p2

p3

p1

d •p gives new coordinate of p along new axis d

dotProd (d, p) = d.x * p.x + d.y * p.y

Algo Geom / NCTM 08 Reno

p • newYaxis --> new y coord…

x

y

p1

p2

newYaxis

p3

newXaxis

Write a general purpose Rotate (point) function:

p • newXaxis --> new x coord…

p’ = [ p • newXaxis p • newYaxis ]

Algo Geom / NCTM 08 Reno

New point values after rotation…

p1_prime = rotate ( newXaxis, p1 );

y/

x/

p1/

p2/

p3/

p1 = unrotate ( newXaxis, p1_prime );

Algo Geom / NCTM 08 Reno

Editable tilted rectangle problem…

Algo Geom / NCTM 08 Reno

2D object intersection problems:

i

L2L1

i1

i2

C1

C2

i1

i2

CIR

L

Algo Geom / NCTM 08 Reno

Problem-solving methodology

Problem statement

Sketch out a mental solution

Write pseudocode

0: dist (c1, c2) > r1 + r2

Translate algo into Java

if (Vec2.distance(C1.c, C2.c)

Test algo graphically

Algo Geom / NCTM 08 Reno

Solve: Intersection of 2 circles

i1

i2

C1

C2

Given: C1 = [ c1 r1 ]C2 = [ c2 r2 ](any possible)

Solve for: numIntersectionPts (0, 1, 2, 3 =∞i1 i2

Algo Geom / NCTM 08 Reno

Subproblem: How many intersection points?

# numIntPts Draw examples Decision logic

∞identical (C1, C2)

dist(c1 , c2) == r1 + r2

dist(c1 , c2) == abs(r1 - r2)

dist(c1 , c2) > r1 + r2

dist(c1 , c2) < abs(r1 - r2)

none of the above

Algo Geom / NCTM 08 Reno

x’

y’

C1’

C2’

Subproblem: Locations of intersection points?

i2

C1i1

C2x

y

newOrigin

translatecoords i2’

i1’

newXaxis

rotatecoords

C1’’ x’’

y’’

C2’’

C2’ = translate (newOrigin, C2)C2’ = translate (C1.c, C2)

C2’’ = rotate (newXaxis, C2’) C2’’ = rotate (C2’.cnorm, C2’)

i1’’

i2’’

Algo Geom / NCTM 08 Reno

a2 + h2 = r12

b2 + h2 = r22

a2 - b2 = r12 - r2

2

(a + b) (a - b) = r12 - r2

2

c (a - b) = r12 - r2

2

a - b = (r12 - r2

2) / c

a + b = c

2a = c + (r12 - r2

2) / c

c = C2’’.c.x

i1’’ = [ a h ]

a = (c2 + r12 - r2

2) / 2c

i2’’ = [ a -h ]

h = sqrt(r12 - a2)

2a = c2/c + (r12 - r2

2) / c

a = (c2 + r12 - r2

2) / 2c

x’’

y’’

C2’’i1’’

i2’’

a b

h

c = a + b

c

r1 r2

C1’’

Algo Geom / NCTM 08 Reno

x’

y’

C1’

C2’

Subproblem: Locations of intersection points?

i2

C1i1

C2x

y

newOrigin

translatecoords i2’

i1’

newXaxis

rotatecoords

C1’’ x’’

y’’

C2’’

C2’ = translate (C1.c, C2)

C2’’ = rotate (C2’.cnorm, C2’)

i1’’

i2’’

i1’ = unrotate (C2’.cnorm, i1’’) i2’ = unrotate (C2’.cnorm, i2’’)

i1 = untranslate (C1.c, i1’)i2 = untranslate (C1.c, i2’)

Algo Geom / NCTM 08 Reno

Java coding…

Algo Geom / NCTM 08 Reno

Exploring Problem Challenges…..

a

60 socket rotating caddy

x

y

wt

c

Algo Geom / NCTM 08 Reno

Exploring Problem Challenges…..

“I’m crashed in the Nevada desert, and this will be my last call. I’ll give you the info you need to place my location on a curved search path…

Mt. Whitney Mt. Ritter

30 30

36 19/128

Algo Geom / NCTM 08 Reno

3D algoGeom

Algo Geom / NCTM 08 Reno

Develop formal representations for these 3D objects:

• planes

• lines

• coordinate rotations (rotators)

• spheres

• circles

Object intersections:

plane-plane plane-line 3-plane

sphere-sphere sphere-circle 3-sphere (GPS)

x

z

y

o

l

• 3D direction vectorz

x

y

[ 1 1 1] [-1 -2 2]

d1

d2

unitsphere

[-.33 -.66 .66][.58 .58 .58]

x

z

y

newZaxisnewXaxis

newYaxis

x

z

y

L

newZaxis

z/

L/

x/

y/

[ x/ y

/ ]

L

PL1 PL2LPL

i

SPH1

SPH2

CIR

SPHCIR

i1

i2

Algo Geom / NCTM 08 Reno

3D graphicsworkspace

QuickTime™ and a decompressor

are needed to see this picture.

Algo Geom / NCTM 08 Reno

Results from 2005 pilot course

student feedback:

getting my computer to do all the gruntwork - way cool!

Java programming picked up in 2 weeks

gave me advantage later in college math/engineering

elegant compared to traditional geometry / trig

course “proof of concept”:

syllabus fit into 72-hours classtime (no homework)

labs easy to grade

learning results impressive - student programs sophisticated seek funding for feasibility

Algo Geom / NCTM 08 Reno

Example of student work (from final exam)

Algo Geom / NCTM 08 Reno

Summary of algorithmic geometry

spatial problem-solving as human-computer partnership

representations modernized for ease-of-algorithm-writing

concepts scale up intuitively from 2D 3D

surge in problem-solving confidence

learn Java programming by osmosis

fast-track for students considering STEM

Algo Geom / NCTM 08 Reno

How can I get involved?

Participate in Algorithmic Geometry summer workshop

Pick a student TA w/ Java - we’ll train you as a team

Team-teach a pilot course on your home turf

Get paid as educational researchers

Help leapfrog U.S. math education

Contact Algo Geom Project:

[email protected]

925-200-1558

Pierre Bierre

(contingent on funding)

Algo Geom / NCTM 08 Reno