Wednesday, December 26, 2012

GeoGebra Animation

There was a challenge to make a GeoGebra Christmas card this year, through Instagram with a #ggbxmas tag, and there were a few really sterling entries. Like this one from Wengler, a lovely Pentomino puzzle from Renata, or milanoff's slick animation. I'm not an Instagrammer (yet)...

... but I tried to make a card too, and just wanted to share two bits that helped me make my mediocre effort. Making the card made me think that this would be an excellent class challenge, which could really help contextualize some algebraic topics.

The above image was made using GeoGebra's nice export to animated gif feature. The original sketch is at GeoGebraTube.

The first was to make a function that would be 0 for a while, then increase to 1, then stay at 1. There's smooth (mathematically speaking) ways to do that, but a piecewise linear function is good enough for most uses:
f(x) = If[x < 0, 0, If[x < 1, x, 1]]
Then it's a really nice use of graph transformations to adapt it. Want it to start increasing at x = 5? f(x-5). Want it to scale between 0 and 4? 4*f(x). Want it to take  6 units, starting at x=3, to increase from -1 to 8? That's a good problem! (Would 9*f((1/6)(x-3))-1 work?)

My first couple of pieces were animated by using the function directly on a point definition. Like Joseph's left foot,
A=(12f(1 / 3 d), 0)
and then I defined the rest of Joseph relative to that point. In GeoGebra you can do arithmetic with points like vectors and use the coordinate commands to reference part of a point.
A+1 = A+(1,1)
B=A + (0.5, 0)
C=0.5 (A + B) + (0, 1)
(x(A), y(A)+1)
W=(0, 1) + f(1 / 8 (d - 4)) ((12, 1) - (0, 1))
But then I realized that instead of animating each vertex, I could make the shape I wanted, and then use geometric transformations to move an image of it, controlled by a vector. So for the second time moving the Holy Family into the stable, I made vectors like:
Joe = 2.5(f(d - 7), 0)
Vector[(5f(d - 7), 0)]
And then moved shapes by translating by that vector.
poly7'=Translate[poly7, Mary]
I used the translate tool to do that, clicking on the names in the algebra view, but this is how it looks as an input bar command or in the algebra view. (Took me a while using GeoGebra before it occurred to me that using tools you can select from the algebra view, and that I didn't have to be able to click on it in the sometimes complicated graphing view.)  This technique is much more powerful, and lets you fine tune by changing the vectors instead of having to go change multiple vertices. Which is the kind of thing I have told students in linear algebra before, but never really had to do!

So Merry Christmas and Happy Holidays to all, and a GeoGebrafied New Year!

1 comment:

  1. Very nice and smart. Wish you a Happy New Year