Drag & drop points to a desired location

Feel free to post your improved solution!



Detect when objects are in the “correct” location to provide user feedback.

(Select) Challenges:

  • Desmos GRAPHS do not appear to support boolean algebra: Must get clever… see “Details on workarounds” below.
  • Cannot independently set color of control point and its text (unless you use LaTeX, I suppose). Needed to copy all points to generated labels of desired colour.
  • Cannot generate array of string (only numeric values). Could have created labels for point as a >>single<< array (instead of 4 seperate PLi points).
  • Labels do not have access to index variable like you do for the “on-click” event. This also would have allowed me to bundle-up the labels in a >>single<< array.
  • Cannot

Details on (select) workarounds

  • Seems like sign() function is our best tool to carry out logical operations in graphs. It would be nice to get access to boolean operators (I don’t believe sign() is particularly intuitive for most people).
  • To check for equality in this example: sign() was used on the distance between a point & its intended location to see if is “home”.


Many of the workarounds I described above make it inefficient to build activities. The amount of “code”/lines you need to manage for even simple activities gets somewhat unwieldy. I fear issues like these might dissuade many from creating interesting activities.

Some of my personal hurdles:

  • Handling state within a graph widget.
  • Handling event detection.
  • Re-thinking how to do simple <, =, > comparisons.
  • Needing to manage/hide multiple objects because we can’t easily manipulate colors, text “on an event”.
  • Managing large number of “code” lines - because of duplication (Folders are not sufficient for more complicated activities).

You may be able to use conditionals to achieve what you want.


The above is essentially “If the distance from P1 to PH1 = 0, then 1, otherwise 0”.

You can also create a list of rgb( ) values to have a list of colors, which will show up in your color options if you wanted to more easily change text/points.

Thanks @Daniel_Grubbs !

  • I was unaware of the distance() function.
  • I’ve actually never seen the “ternary operator” version of conditionals before. Thanks!

I completely forgot about conditionals as a means to hide objects. I am in the process of changing other activities that were multiplying by 0 to make stuff disappear. Conditionals are much better!

  • I have only ever seen the {x<a} version to restrict the domain – so thanks for that!
  • I have been using something more like y=mx+b {B_wantshow = 1}. I think it works a bit better for this application.

Can you expand on this? I think I might have seen an example log ago, but I have since forgotten about it.

Here’s a quick one. Notice I used a list for conditional display as well, which you might be able to use in conjunction with actions.

Thanks for the example.

This does not appear to let me independently set the colour of a point from its text label, but good to know you can independently set colours of different points in an array.

Oh very nice! I had a go before digging into your approach, and there’s definite similarities: Untitled Graph

I used distance(A,B) in my check, while you went with “sign of the length for vector A-B”. I can see both methods being preferred in different contexts; really just boils down to how you want to think about the logic!

I’ll call out especially line 34 (where I get a list of strings!). Also, ctrl+f (or cms+f) is invaluable for those more involved builds.

Detecting “correctness”

Well, that’s because I was unaware of the existence of distance(A,B) before @Daniel_Grubbs told me. I much prefer your method here.

Note that you can simplify your statement a bit:

  • IsCorrect={distance(Ptargets,Pmovers)<1:1,0}

can be reduced to:

  • IsCorrect={distance(Ptargets,Pmovers)<1}

This effectively gives a boolean… though you still need to use [1=I_sCorrect] to use it later on (as, apparently Desmos treats it as a number — not a true boolean).

List of strings

Oh yeah. I forgot I can do that. I have used it before in other graphs.

It is somewhat unfortunate that I cannot store this “list of strings” for later evaluation (like I can with lists of numbers). However, at least “interpolating” values from a list to generate a “label” makes it possible to do some simplification to our code.


Good to know. Didn’t even think to look for a search tool.

1 Like

Alternative way to draw circles

Excerpt from @aknauft’s code:
Well that is an awesome way to draw a circle in Desmos!

I didn’t know you could “instantiate” a parameter, t, like this! I can’t actually figure out what triggers it to be generated. I tried using t with the following statement:


…but Desmos assumes “t” means “x”, and draws a sin-wave going from -inf to inf.

Request for documentation

Where is the documentation for this “localized parameter” anyhow?

Yeah, I like doing (cos(t), sin(t)) for circles. Desmos treats t as a special parameter when it’s used with an (x, y) structure, turning it into a parametric equation! Relevant documentation: https://help.desmos.com/hc/en-us/articles/4406906208397-Parametric-Equations

You can use (t, cos(6.28t)) for this; I think Desmos largely expects an ordered pair.

Some useful info here:

I see: parametric equations only exist on ordered pairs. Makes sense… just wasn’t expecting that to be the trigger (nor the fact that “t” would be special somehow).

Thanks for the help @aknauft & @pirsquared!