Graphing a Set of Polygons

Is there a way to graph a set of polygons? I am trying to use aggregate to get a set of triangles.

The simplified version is if I have 6 lists for the x-coordinate and y-coordinate of the 3 vertices. How can I graph the entire set? The best I have been able to manage is see all of them using a slider where “n” indexes the list of triangles.

Example:Graphing Calculator

For that I personally would use:

A=(A_x,A_y)
B=(B_x,B_y)
C=(C_x,C_y)
polygon(A,B,C)

When you use lists of equal length, it matches elements together so you don’t need [n].

That is what I am using, but it only graphs one polygon.

For my A_x, A_y etc. they are lists of numbers, so without the [n] it fails to graph as it interprets it as a list of lists.

Oh sorry, you can’t use lists within lists. So you’d need:

polygon(A[1],B[1],C[1])
polygon(A[2],B[2],C[2])
polygon(A[3],B[3],C[3])

Or you could join your lists (A,B,C) into one list L

polygon(L[1,4...9])
polygon(L[2,5...9])
polygon(L[3,6...9])

There is a hacky way to plot a set of polygons. The main idea is to merge everything into a single list, manually “close” each polygon by repeating the first point, and “restart” the polygon drawing by inserting an undefined value between each.

In your graph, I joined (A,B,C,(0/0,0/0)) and manually re-indexed so that it would connect [a1,b1,c1,undefined; a2,b2,c2,undefined; …]: desmos.com/calculator/s0feftgikl

Here’s the same idea, but with the potential for an arbitrary number of triangles: desmos.com/calculator/a6lsmnwit4.

The calculator still thinks you are trying to draw a single polygon, though, so the fills can sometimes intersect with one another and “undraw” portions. If you define your coordinates manually, you can choose a consistent orientation to connect the dots and should be able to avoid this.

2 Likes

That’s sneaky. I like it.

Very cool. I had this without the brilliance to slip in an undefined to reset… so it was just one massive polygon.

I wound up doing a different workaround with the equations of the 3 lines that’d connect the points as inequalities.

…and after a days work. I got a functional start to an activity.

3 Likes

Below is an alternative approach that seems to work ok. I am joining this thread a bit late, due to running across it from googling. I’m not sure if the approach here would have worked when the thread was first started, or whether Desmos added these capabilities later.

Raj

With list comprehension, desmos allows you to actually create lists of polygons. Here’s a more compressed method.

Nice, thanks! My apologies that I didn’t see your reply sooner. It’s a beautiful technique, and very powerful use of list comprehension. Thanks!

Here’s something I made recently. It doesn’t use your nice trick of making a list of polygons, but it draws a polygon from a variable-length list of coord-pairs, so that the same command can draw a regular n-agon for different values of n, eventually approximating a circle:

Raj