Making a Vector in Desmos

A couple of years ago, during a workshop on transformational geometry, a participant objected when I used and recommended GeoGebra and not Desmos. Her main argument was that students love Desmos. Fair enough, but that does not make up for the fact that Desmos is about graphing, while GeoGebra includes the many basic and not-so-basic geometry features, which we needed for this work, and were not available in Desmos.

Since then, both programs have improved in multiple ways. I have a lot of experience with GeoGebra, which was easy for me to learn as its interface is largely the same as Cabri’s. (I had been using Cabri for many years.) Desmos still does not include geometry, but I am learning to use it, and I love many things about it. If I was still in the classroom, I’d love it even more. (Check out my first Desmos applet: Stairs.)

In any case, I am certain that it is every math teacher’s responsibility to keep developing their skills with both GeoGebra and Desmos, so as to know which one is appropriate in any given situation.

My intention in this post is to report on a current project of mine. Decades ago, I wrote an excellent pair of games in the Logo language: one modeled signed number arithmetic, and the other modeled complex number arithmetic. Both games were built on a foundation of vectors. They were fun and effective. When Logo went out of fashion, I created versions of the complex number game in (now-defunct) Logo descendants: first Boxer, then BYOB (which evolved into Snap!) Alas, while these worked well in my classes, they were largely unavailable to teachers outside my school.

About two years ago, I created a GeoGebra version of the complex numbers game for my Web site. It works, and still has the mathematical and pedagogical strengths of the original, but the interface is awkward, and I suspect few people have played it. As part of learning Desmos, I decided to try to create my arithmetic games as Desmos applets.

Imagine my surprise when I found that Desmos has no built-in way to create vectors, something that is trivial in GeoGebra, and relatively easy in Logo and its descendants. If I’m ever going to create a version of those games in Desmos, I first need to figure out a way to draw vectors.

Well, I managed to do that. Here are some notes on how I did it.

Making a segment from the origin to (a,b): use parametric equations.

Same size and direction, but sttarting at some other point:

And now, the main challenge: making the arrowhead.

Let’s say each half of it makes an angle θ with the line segment, and has length 𝓵. Let’s start with the upper half. The plan is as follows: first figure out the formula at the origin, and then translate to (a,b).

At the origin, the angle with our original segment is 180°– θ. To get the endpoint of the half-arrowhead, we need to rotate our original segment by that angle, dilate it to length 1 by dividing by its length, and finally multiply it by 𝓵. It is a quick calculation using complex arithmetic:

Choosing 0.6 for 𝓵 and 30° for θ, and separating real and imaginary parts, we get:

Placing this at the head of our vector requires one final translation:

And there you have it. A similar calculation yields the other half of the arrowhead, and we have a decent looking vector, which we can control by way of four sliders. Go see the actual graph, chez Desmos.

The most satisfying thing about all this is how quick the essential calculation was, with the help of complex numbers and transformational geometry. I rather stunned myself when everything “just worked” with no need for trial and error.

Of course, native vectors would be a lot more convenient, not least because it would make them accessible to students.

–Henri

PS: Someone at Desmos added movable points to the vector. Check it out. Not useful for my purposes, but maybe useful for yours!