CL Newsletter, February 2022 - A Better Way To Interpret Sketches

We’d like to start off this month’s newsletter with a HUGE announcement: If you’ve ever wanted to join the Desmos team, we’re hiring! Check out the careers page to see our open positions for graph specialist, Computation Layer specialist, and more!

A Quick Hack From Team Desmos

The sketch component has always been a great creative space for students to work freely (not to mention, make some really cool things). But reliably interpreting what a student sketches has always been a challenge. Take lines for example.

We can find the y-values of a sketch at any given x-value (or vice versa) using xValuesAt and yValuesAt, which gives us the ability to build an invisible grid that detects places where the sketch crosses through a grid line.

If a student uses the line tool and sketches a single line, the points can be used to calculate the equation of the line drawn by the student.

But this technique alone is unreliable because lines that don’t cross through two gridlines or sketches that contain more than one line (including freehand) lead to incorrect results.

How We Fixed It

Part 1:

You can now block bad lines from being drawn with a few non-CL options, which allow you to restrict the tools that can be used in a sketch component! Just open the ellipsis menu and deselect the tools you don’t want to allow.

Part 2:

The second tool is truly a fun hack. It involves transforming the sketch to something more manageable and using that sketch to find the endpoints. Here’s how:

Start by adding a transformation that preserves your x-coordinates, but flattens the y-coordinates down to 0. Not familiar with transformations? Learn more here.

Now that every sketch point is flattened to a single y-value (0), find the minimum and maximum x-values at that point. These are the x-coordinates of your endpoints.

Once you’ve found the x-coordinates of your endpoints, find the y-values at those points.

With those endpoints, you can do whatever you want (drawing a line through and calculating the slope and y-intercept immediately come to mind).

Try This Demo Yourself

Note: This “flattening” trick doesn’t just work on lines. Check this activity out!

Part 3:

These remedies still leave us with one tricky conundrum: how do we prevent students from drawing more than one line? For that, you have some options. You can block students from sketching after a single line has been drawn or you can have each line replace the previous one. And there may be more! If you have another solution, share it with us!

Rather than go into detail for these two options, we’ll let you try them out and choose the option that works best for you.

Try It