Lessons taught; Lessons learnt

Maths, teaching and beyond.

Archive for the ‘geometry’ tag

Curves and splines for fun and profit

with 2 comments

Imagine you are given some points, and asked to join them together. Probably the easiest way to do this is to use straight lines:

connected-with-straight-lines

What if we wanted the line joining these points together to be a curve, rather than a sequence of straight lines? Even better, to be a smooth curve (in other words, to not have any sharp changes in direction)? One of the simplest ways to do this is to move into the world of Bézier curves.

The geometry of Bézier curves

Beziér curves are a class of surprisingly easy to generate curves which can be specified completely by a small number of points. Here is how to geometrically construct the two most common types of Bézier curve:

First, a quadratic Bézier curve:

To see this Geogebra worksheet, please enable Java.

Second, a cubic Bézier curve:

To see this Geogebra worksheet, please enable Java.

(Both of these are interactive -- move the blue points around and see how the curve changes.)

It should be obvious that we could continue this process with more and more control points to get Bézier curves of even higher orders.

From curves to splines

These curves are very nice, but they only go through the first and last points, with the others acting like 'control points', influencing the direction of the curve. If we create a Bézier curve using all the points given earlier, for example, we get this:

degree6-bezier

To connect up the points we are going to need to join together several of these Bézier curves, to form a spline. The full theory of splines is very complicated, but we can make a good start by connecting together a bunch of cubic Bézier curves:

curve-to-spline

If you have ever used a vector graphics package (like Inkscape, Illustrator or Coreldraw), this is exactly how they create paths through specified points. They tend not to draw the line segment connecting the two control points together, which makes the path look like this:

Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and active in your browser (Click here to install Java now)

Playing with the path above, you soon notice that it is very easy to get kinks (cusps) at the points where the Bézier curves meet. We can avoid this by making sure that the control points before and after a curve point are on the same straight line. Drawing packages also usually make the control points the same distance away from the curve point, giving you something like this:

Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and active in your browser (Click here to install Java now)

There is still too much choice here, though -- remember that we have just been given the points for the curve to go through. We can get a fairly nice curve, which just depends on one parameter (the 'curviness', lambda), by setting the control points as follows:

Given points X_0 up to X_n, for i \in \{1, \ldots, n-1\}, set the control point to the left of X_i to be X_i - \lambda \overrightarrow{X_{i-1} X_{i+1}}, and the control point to the right of X_i to be X_i + \lambda \overrightarrow{X_{i-1} X_{i+1} }.

In other words, the line between the two control points is parallel to the line between the two neighbouring curve points, and the distance is proportional to the distance between the curve points.

We also need to decide what to do with the control points of the ends of the curve, X_0 and X_n. Probably the simplest thing to do is to set the control points equal to the curve points themselves.

This gives us something like this:

Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and active in your browser (Click here to install Java now)

I call the parameter the 'curviness', because the spline becomes more and more like a collection of straight line segments the closer lambda is to 0. The higher the value of lambda, the more pronounced the curve is -- and interesting things happen if lambda becomes negative!

Solving our original problem

We can now solve our original problem, by connecting our collection of points together with an appropriately generated set of Bézier curves. We might decide to have an 'open' curve (with endpoints):

Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and active in your browser (Click here to install Java now)

or indeed to create a 'closed' curve, treating all the points equally:

Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and active in your browser (Click here to install Java now)

Why not see what different types of shapes you can generate from these seven points? How close to a perfect circle can you get, for example?

Further notes

Without realising it, you have been looking at Bézier curves for years: every scalable Truetype font is defined using quadratic Bézier curves, and many other font systems use quadratic or cubic ones. The mass use of scalable fonts (first popularised in the Postscript printing system) was a major innovation, rendering the old bitmap system, where fonts came in one particular pixel-based size, almost entirely redundant.

Interestingly, Bézier was not the first person to discover, or to work with Bézier curves. One of the most common algorithms for drawing Bézier curves is due to de Casteljau, who was working with Bézier curves several years before Bézier! 

Although probably the most common, Bézier curves are certainly not the only choice to use for splines. If you are interested, see this Wikipedia article for more information than you probably wanted on the deeper mathematics behind them.

A Geogebra postscript

All the interactive sections above were generated using Geogebra. Double-clicking on any of them will open the interactivity in its own window, where you can save it to your computer, or explore how it was generated. If the interactivities are not there, then the Geogebra website is probably down!

One of the features introduced in version 3 of Geogebra is custom tools. I have created one of these custom tools which will let you easily create cubic Bézier curves. Simply open the following file: cubic-bezier-tool.ggt, and you will see a cubic Bézier tool appear in the toolbar.

Appendix: The algebra of Bézier curves

The reason for the names 'quadratic' and 'cubic' becomes clearer when we try to figure out an algebraic way to generate Bézier curves. It is apparent from the geometric construction that the key to constructing these curves is to move a certain proportion of the way between pairs of points, and then repeat this process until we have only one point, which will trace out the Bézier curve.

We will build up the formulae from the simplest case:

linear-bezier

Straight lines (linear Bézier curves): If t is a parameter between 0 and 1, then the point tth of the way between A and B is P_{AB} = (1-t)A + t B. As t changes, P_{AB} will trace out the line segment AB. This is sometimes called linear interpolation.

quadratic-bezier

Quadratic Bézier curves: We are given points A, B, and C. From these we generate the two points P_{AB} = (1-t)A + t B and P_{BC} = (1-t)B + t C. Moving tth of the way between these two points we generate P_{ABC}:

eqn5007

Rearranging and simplifying, we get

P_{ABC} = (1-t)^2 A + 2 (1-t) t B + t^2 C.

This will trace out our quadratic Bézier curve.

cubic-bezier

Cubic Bézier curves: We are now given four points, A to D. We can generate two quadratic points, P_{ABC} and P_{BCD}, with equations as above. Combining them, we get P_{ABCD}, which will trace out our cubic Bézier curve. The simplified form of its equation is:

P_{ABCD} = (1-t)^3 A + 3 (1-t)^2 t B + 3 (1-t) t^2 C + t^3 D.

We could continue this as far as we wanted, to get equations for higher order Bézier curves.

Written by Jon Ingram

March 31st, 2009 at 10:56 pm

A quickie on quadratics

with one comment

Fix two points in the plane, and consider all the quadratics which go through those two points.

Find the locus of the stationary points of these quadratics.

The following Geogebra worksheet might help. If you select “Show stationary point” and move the blue point, it will trace out the locus.


Geogebra applet (enable Java to see it).

(Source: quadratic_stationary_points.ggb.)

Thinking about this question kept me from going to bed until far too late on Thursday. My answer, and other thoughts, will appear tomorrow.

Written by Jon Ingram

August 23rd, 2008 at 8:20 pm

Posted in Maths, Puzzles

Tagged with , , ,

The Joy of Hex

with 14 comments

(Update: This post is featured in the 39th Carnival of Mathematics. Check it out!)

Last summer I developed a bit of an obsession with hexagons. More specifically, with the patterns you can produce from tiling multiple copies of a single, simply decorated hexagonal tile:

I cut out and laminated around 100 of these tiles, and spent several happy hours moving them around into new patterns, trying different types of symmetry, and experimenting with different layouts.

If you’d like to follow me down a similar path, here’s a sheet with six of these hexagon tiles to print and cut out: hexagon-tiles-122.pdf (svg source), made using the free vector drawing program Inkscape.

Background

Although I wasn’t aware of precursors at the time, I later found this shape in several places: it is one of the tiling generators you can buy from the ATM, and it’s one of the tile shapes in the game of Tantrix. I recommend you browse the ATM’s store if you are a maths teacher — many excellent things await!

I also recall reading a very interesting web page which found this exact pattern being used as a paving slab in Spain, and developed quite an in depth mathematical discussion, but sadly this page now seems to have disappeared into the æther.

Although less common than they used to be, hexagons were often used for tiling and paving. I particularly like this hexagon paving tile designed by Gaudi, and used all over Barcelona.

Returning to the particular hexagon above, we get the following when we tile it:

The fun comes when you rotate some of the hexagons. Even with just six patterned hexagons you can find a range of different interesting patterns… but it’s much more fun to explore with a large pile of them!

In My Classroom

At the start of last year, the tiles appeared on my classroom walls in the place now occupied by the Pascal’s Triangle wall display. As with Pascal’s Triangle, the tiling wasn’t static, but slowly changed form and shape over time, and several interesting questions were raised by some of my groups (several of which couldn’t believe at first that all the different patterns were generated by a single type of tile).

Eventually the hexagons migrated over to the other side of the classroom, and took the form revealed in the very first post I made on this site:

Read more for: more examples of patterns you can produce from these tiles; some questions for you to explore; my thoughts on the mathematical content of this ‘pattern space’; and source files for all the diagrams.

I suggest you pause here, print out the hexagons, and have a play before continuing.

Some Patterns

Here are eight patterns made with the hexagon tile, on a 6-by-6 grid:

(click on the images for a better view). These by no means exhaust the patterns you can generate with this tile.

Questions Raised by the Patterns

I believe that these tilings form a rich and non-trivial environment for pattern spotting, and the generation of mathematical questions and conjectures in the classroom. Here, for example, are some questions which occurred to me as I was exploring the ‘pattern space’:

  • Several of these patterns have rotational symmetry of order three. What other rotational or reflectional symmetries are possible? What about if we allow ‘holes’ (i.e. we don’t have to place hexagons in every grid position)?
  • The last of the 6-by-6 patterns demonstrates glide reflection. There are seven possible frieze patterns; can we generate examples of all of them?
  • Various motifs recur in different patterns: a small circle using three hexagons; an oval using four hexagons; several braids; a large circle and a trefoil using six hexagons. What other closed loops can we make using only a small number of tiles? Also, are there any forbidden lengths, with no examples of loops of that size?
  • Fix a small grid size (for example, a 2-by-3 rectangle). How many distinct patterns can we make?
    The meaning of ‘distinct’ here is something that would need to be negotiated with the students. If we take a pattern and rotate or reflect it, should we count that as a new pattern?

I think all these questions could be generated, explored, and altered quite productively by students at a range of levels. They also give students an opportunity to demonstrate several key reasoning skills, such as systematic exhaustion: how can we be sure that we’ve found all the possible patterns of a given grid size, or loops of a given length?

Complexity

In some sense, all the questions in the previous section were combinatorial. We had to count the number of ways that something happened, or generate examples.

Here’s a deceptively simple question which leads into an investigation of another sort:

Which of the patterns above is the most complex?

We might perhaps say that simplest patterns are those which we can describe in the shortest amount of space. The very first pattern, for example, could be described by saying ‘all the tiles are this way up’. How could we describe how to generate some of the other patterns?

Given this view of complexity, what do complex patterns look like?

What do simple patterns look like?

This seemingly naive and simple view of complexity, when formalised, leads to algorithmic information theory, and in particular to the concept of Kolmogorov complexity. This also has connections to an immense body of work in computer science, including compression algorithms.

Transformations

Moving away from complexity, let’s now consider what happens when we start with a pattern, and want to alter (transform) it in some way.

It is obvious that we can transform one pattern into any other pattern by rotating each tile in turn — but what happens when we impose constraints on the ‘moves’ we are allowed to make? For example, suppose we had a rectangular grid of tiles, and were only allowed to rotate the tiles a row/column at a time.

Starting from the basic pattern we saw right at the start:

we could rotate the second ‘column’ one step anticlockwise:

and then the third row:

and then the fourth column:

and then the second row:

Could we generate every possible pattern this way?

This is an interesting question, but probably a little difficult to approach at the secondary school level. So, let’s be even more restrictive:

Suppose we rotate all the tiles at the same time. What happens?

To be more specific, let’s start with this pattern:

What do we get if we rotate all the tiles one ’step’ clockwise?

Now is an excellent time to print out some hexagons and find out!

What about if we rotate again? And again?

What happens with different starting patterns?

What is preserved by this transformation, and what is not? If one pattern repeats every three hexagons for example, then the other one will as well. But what about symmetry? What about the ‘loops’ formed by the lines?

Notice that we are exploring, in an accessible way, several advanced concepts: applying a transformation to something; preservation of features; iteration of transformations among others.

Where’s The Maths?

Usually, in school mathematics, we only consider functions which transform numbers into other numbers — even transformations such as rotation, reflection and enlargement are almost never talked about as functions which can be combined, or reversed, or iterated. This naturally makes it harder for students to ’see the maths’ in situations which don’t directly involve numbers.

One way to help students to become comfortable with these ‘non-traditional’ areas could be to improve the emphasis, throughout their school careers, on key concepts and questions, like iteration (what happens if we do something many times?), inversion (how do we undo what we just did?) and iso- & homo-morphism (what has changed, and what has stayed the same?). These are applicable at all levels of mathematics:

What happens if we add the same number lots of times?

How do I undo a multiplication?

What properties of my triangle stay the same when I enlarge it?

What happens when I differentiate a polynomial lots of times?

How do I undo exponentiation?

What properties of number stay the same if we allow the square root of -1 to be a number, and which have to change?

The same types of question recur throughout the mathematical development of a pupil.

Conclusion

Even something as simple as a hexagonal tile can lead to some really deep mathematical questions, and thinking about them can develop skills which are applicable in many more traditional areas of mathematics.

It also lets you use the pun in the title — and we don’t get the opportunity for puns often in maths!

[As promised, here are the source files for many of the above diagrams.]

Written by Jon Ingram

August 21st, 2008 at 10:10 pm

Midpoints (3): A return to quadrilaterals

with one comment

Constanze, a fellow proofer from Distributed Proofreaders, took me up on my request to find a geometric proof that the midpoints of quadrilaterals form a parallelogram:

To prove that M1M2M3M4 is a parallelogram, we need to prove that M1M2 || M4M3 and M1M4 || M2M3 (definition of a parallelogram).

In Euclidian geometry, two lines are parallel if both are parallel to a third one. The sides of the parallelogram are parallel to the diagonals of the quadrilateral. This can be shown by looking at similarities between triangles: I’ll do this for P1, for the other 3 vertices similar arguments can be made.

Triangles P1M1M4 and P1P2P4 are similar because they share an angle M4P1M1 and the adjacent sides to this angle are proportional: P1M4 / P1P4 = P1M1 / P1P2 = 1/2.

From this follows that angle P1M1M4 = angle P1P2P4 (similar triangles have identical angles). Using the theorem on angles on a transversal to two parallels this means that M1M4 || P2P4.

Discussion of the Geometric Proof

First, note that this takes a completely different route to proving the property than the vector proof I gave in my original post. The key to this geometric proof lies in the observation that the edges of the midpoint parallelogram are parallel to the diagonals of the original quadrilateral. Once this has been noticed, the rest of the proof is just chasing definitions.

Second, I find it very hard to grasp a geometric proof without actually drawing a diagram. So here’s a picture, showing the two diagonals of the quadrilateral:

Costanze’s proof concentrates on one of the four edges of the quadrilateral. Here’s a diagram without the extraneous material:

Comparing the Proofs

Both the vector and the geometric proof are equally valid, but both have different characters, and can be easily generalised in different ways. With the vector proof, for example, we could easily start looking at points which are, say, 10% of the way from one vertex to another. It also doesn’t require any extra diagrams. Technically the geometric proof doesn’t require diagrams either, but I would be very surprised if anyone ever does any geometric proof without having some sort of picture in mind.

One advantage of the geometric proof is that, by identifying the importance of the diagonals of the original quadrilateral, it helps us to answer some of the additional questions raised in the original post. For example, for our midpoint parallelogram to be a rectangle, we need the diagonals of the quadrilateral to be perpendicular. This means that the midpoint parallelogram is certainly a rectangle if our quadrilateral is a kite (or inverted kite). Deciding whether this sufficient condition is necessary (and the further question about when the parallelogram is a square) is an exercise for the reader!

Why Bother?

After we have one proof of a proposition, why should we bother looking for other ones? I run in to questions like this one all the time in teaching, particularly when I am trying to get my students to find their own explanations. There are several reasons.

For one, it is a useful mental exercise to think about a situation in different ways (for example, finding the minimum point of a quadratic using differentiation, and also using completing the square).

Secondly, different proofs of the same proposition can differ hugely in elegance (an area which is incredibly hard to discuss at school level, particularly as we seem to have almost completely removed proof from anything lower than Further Mathematics).

Thirdly, as mentioned above, different styles of mathematical thinking lead themselves to being generalised in different ways (we can easily prove things with vectors in more than three dimensions, which is certainly hard to picture!).


Written by Jon Ingram

August 3rd, 2008 at 1:10 pm

Posted in Maths

Tagged with , ,

Midpoints (2): Pentagons

with one comment

Following on from the previous post, here is an applet which dynamically generates a pentagon, given the midpoints. Have a play around, and then continue reading for some follow on questions.


Geogebra applet will be here if you enable Java.

(Source: pentagon_given_midpoints)

This does demonstrate that we can find a pentagon with any given midpoints, but is it definitive evidence? No, for a very important reason: with any dynamic construction, we will only be able to test a finite number of points… a proof needs to be true for every possible combination of midpoints.

Also, although the applet gives a single pentagon for each combination of midpoints, that doesn’t mean that there aren’t others… it just means that I’ve only constructed one solution in this applet.

Just as with the previous post, on quadrilaterals, it is in fact easy to show using vectors that there is a unique solution for any possible combination of midpoints. In addition, the vertices of the pentagon have a very nice vector representation in terms of the midpoints… but I’ll leave finding that representation to you!

Here are some interesting follow up questions about this situation, which you might want to think about, possibly with the help of the applet:

First, suppose we keep four of the points fixed, and alter the position of the fifth midpoint. Can we find a simple description of what happens to the vertices of the pentagon as we move the midpoint around?

Second, a lot of the midpoint configurations give results which are not ‘traditional’ pentagons. Like these, for example:

Can we find a restriction on the position or the order of the midpoints which rules out these shapes which have edges intersecting at points other than the vertices?

Third, it’s fairly simple to generate ‘degenerate’ pentagons which are really quadrilaterals:

Can we explain which configurations of midpoints lead to quadrilaterals?

Fourth, is it possible to generate degenerate pentagons which are really triangles in the same way?

I’m sure we can come up with other questions (and I’d like to hear about any interesting results people find), but there’s enough here to keep me going for the moment!


Written by Jon Ingram

August 2nd, 2008 at 8:38 pm

Posted in Maths

Tagged with , , , ,