# Is it possible to generate a set of lines based on a list of points?

Apologies for the formatting, I’m a newbie with Desmos and this is my first post so I’m trying to make the code readable

I want to draw a series of lines from one point, say Q, each to one of a selection of other points in a list. For example

N = 10
D = [(x,y) for x=[-N…N], y=[-N…N] ]

D is a square grid of points covering -10 to +10 in both x and y.

R = 3.5
C = D[ D.y^2 + Dx^2 < R^2 ]

C is a list containing the subset of the grid of dots that lie within a circle of radius R, so far, so good.

P = (2, 1)
Q = (-3, 4)

Writing:
P, Q
draws a line from P to Q.

What I would like is to create a set of multiple lines from P to each element of C by writing:
P, C

That fails with the message “Cannot combine a point with a list of points.

Is there a way to achieve this, and if graphic operations cannot use a list of points, what can be done with such a list?

The aim is to illustrate Newton’s Shell Theorem by drawing force vectors and having them dynamically shown depending on the radius and thickness of the shell.

Do you want the screen to show all the points immediately? At the same time? Because you could use an action button to generate lines so students can generate as many lines as they want…

Drawing all possible lines that fit the condition at the same time would sort of look like a filled-in circle.

1 Like

Like this? Using f(x,y) as a difference function without a fraction helps avoid undefined vertical lines. The .x and .y are ways of accessing individual coordinates of a point.

1 Like

Daniel, that is exactly what I needed, thank you. The result is just a beginning and needs a lot of refinement but this is a great starter.

Stoyan, I have other projects in mind where having buttons and perhaps a canvas with more than one graph would be very advantageous but the help pages start with adding something to a screen without saying how to create a screen to which things can be added. Clearly I’m missing something very basic but I’m only just learning the syntax as you can see (I only heard of Desmos a couple of weeks ago) so that will be a “learning opportunity” for the future. Any pointers to taking that first step would be appreciated though.

Here is an example of a screen with action buttons.

1 Like

Thanks Stoyan, I saved a copy and that took me to the screen where I can now create a new one, just what I needed.

Best regards
George

1 Like