# Perpendicular Lines and Coding a Tartan

Linear functions are at the heart of 8th grade math and Algebra I, and I enjoy finding those ways we engage with functions in real-life situations… including creative coding!

As we learn about slope, it’s an interesting challenge for students to explore what kind of line would be perpendicular to a given line, and I like to use that challenge to deepen their understanding of what slope is. We start with some lines and without showing them how, I challenge them to find a line that makes a perfect 90 degree angle to the given line.

Perpendicular Slope Worksheet

We have a discussion about when this understanding would be important. Architects or designers might use the concept, for example, if they have to design right-angles that are not perfectly aligned to their grid. Video-game designers may use the concept if a shooter is facing an enemy, and you have to strafe at 90 degrees from the angle you expect their projectile to come from.

Or, you might use the idea of perpendicular lines to just make pretty art, which is what we did with this mini-project.

I reminded the students about Tartans and how groups in Scotland use a Tartan as part of their identity – whether region, occupation, clan, or something else.
https://www.scotlandshop.com/us/tartan-finder

My family and I hiked in Scotland this past summer and noticed tartans of the MacDonald and Campbell clans everywhere!

For math projects, I’ve written before about how much I like coding in Khan Academy’s Javascript interface, so here’s the pitch again: it’s great for mini-projects. It’s easy to push a sample project out to students, easy to debug and run, fun and engaging to color and animate, easy to save and share as long as you have a KA account.

We start by going over how to color the background and stroke and fill colors, and how to place points on the coordinate grid. We first discuss where (0,0) might be and then discover together it’s in the upper left (!) and I challenge students to place points in all four corners and in the center. This is what they end up with.

Then we add in the draw() loop and get the points moving.

Coordinates Program animated

That’s day 1. On day 2, we can introduce the project. Students have to make a personalized, unique Tartan with colors and stripe widths they choose. The tartan must have at least 8 lines on a colorful background. The lines must be perpendicular, but can’t be perfectly horizontal or vertical, or at a 45 degree angle. Lines must start at an edge.

It gives some interesting challenges as students figure out what coordinates would start a line at the edge they want, and then how to create slopes that are perpendicular. In an example video, I show how a slope of +4 in the x direction and +5 in the y direction is exactly perpendicular to a slope of -4 in the y direction and +5 in the x direction. Make one value negative, and swap x and y.
Perpendicular Lines video

My last class made some very nice tartans.

Bryson’s Tartan

Tessa’s Tartan

It’s a quick, 2 or 3 day mini project that gives students some context for slopes and intercepts and allows them to get a little creative.

Enjoy!