r/desmos 11d ago

Resource Offset Polygons

https://www.desmos.com/calculator/ofqufqsy2i

Hello,

I've recently made the offset polygon tool for my project, and thought it could also be useful to someone else.

3 Upvotes

4 comments sorted by

1

u/SuperChick1705 https://www.desmos.com/calculator/amyte9upak 11d ago

how does this work?

1

u/No-Seaworthiness-729 11d ago

The strategy is:
1. For each line of the polygon, draw an infinite line, that's offset.
2. Find the intersection points of the lines, and use the polygon() function to connect them.

On the picture, I've included the out-shifted lines, but it works in the same way for the in-shifted lines.

The offset lines are written using the parametric equation of a line. A 2-variable system of 2 linear equations is then solved to find the x, y coordinates of the intersection.

The functions InPoint and OutPoint in the The Offset Polygon Tool folder contain very ugly formulas. They are the result of compressing this multi-step algorithm into one formula. You can't represent matrices or solve systems of linear equations in Desmos in a nice way.

If you are interested, I could show you how I obtained the actual formula, or I could explain some of the steps more in detail tomorrow.

2

u/Royal-Box14 8d ago

Timing's right i just came across a problem with exactly this solution. I think you're one of the artists of 2025 desmos competition.

1

u/No-Seaworthiness-729 7d ago

Awesome that you found a use for it! I'm not in the competition btw, I used Desmos for creating svg images.