# How can I calculate the side length of a regular polygon circumscribed to a circle?

So I have a simple plane and in my Geometry Nodes I instantiated that plane to points on a mesh circle. I have it set up so that I can control how many instances of the plane there are by changing how many vertices are in the circle, then it adjusts the alignment so that the x-axis is aligned to the center of the circle and I want to figure out a way to scale the y-axis so that the edges of the planes meet perfectly when I change the number of instances. I just need a way to figure out what the scale needs to be.

Thanks to @Gorgious, I think I have about 90% of my answer. I'm just stuck trying to figure out how to dynamically calculate the tangent needed when I change the number of sides.

• You should give the question a meaningful title that reflects what your question is actually about. Commented Jan 4, 2023 at 8:40
• not sure how to word it i'll try Commented Jan 4, 2023 at 8:44
• Hello ! This is what you're looking for I think keisan.casio.com/exec/system/1223432660 and the title (and your search engine query) should be "How can I calculate the side length of a regular polygon circumscribed to a circle". so 2*r*tan(π/n) Not really a blender related question, though. :) PS: why not using a mesh cylinder primitive ? i.sstatic.net/yb1cP.png Commented Jan 4, 2023 at 9:02
• thank you so much @gorgious. I guess the blender part of the question was how to implement but I think My biggest hang up was my limited math knowledge (tiny high school never got past basic algebra) so I don't even know the terms to start googling a solution. But I think circumscribed was what I was looking for. As far as the cylinder mesh I tried that path a while back and don't remember why it didn't work but this solution gives me many more options. I am trying to make a procedural lantern generator. basically there will three copies of this node one each for a top mid and bottom section. Commented Jan 4, 2023 at 9:59
• I had to implement the same kind of calculation in geometry nodes to place and calculate the radii of the circles in this question. Check it out, the blend file is available Commented Jan 4, 2023 at 10:09

By trigonometry, the edge-length of a polygon with $$s$$ sides, inscribed by a circle of radius $$r$$, is $$2 * r * tan(pi/s)$$:

But, as @Gorgious suggests, it might be easier to let Blender do the work of arraying the sides, with a cylinder. The radius to the corners of a polygonal cylinder of $$s$$ sides inscribed by a circle of radius $$r$$, is $$r / cos(pi/s)$$:

Both methods demonstrated here:

• @quellenform :D ... I must learn my MathJax! In the mean time, it seems I can rely on the gang.... Commented Jan 4, 2023 at 11:45
• ...I still have to learn that too :D In this case I just used a dollar sign instead of backticks. This cheat sheet often helps me: math.meta.stackexchange.com/questions/5020/… Commented Jan 4, 2023 at 11:48

You can calculate the side of an n-gon as shown bellow:

…and in blender:

If your source cube hasn't got Y width exactly 1, you need to compensate also for that:

Entire solution:

• Seems I wasn't fast enough :D Commented Jan 4, 2023 at 12:12
• +1 ... that's because you were so much more thorough than me. Nicely illustrated :) Commented Jan 4, 2023 at 12:14
• Speed does not always count here. The quality of the answers is crucial! Thank you for your contribution! Commented Jan 4, 2023 at 12:15
• between the two of you I think I got it working. Thanks Robin Betts & Vajtus. Commented Jan 4, 2023 at 12:18
• @KeldrifDarkflame Fyi it is also possible to achieve the same effect with Extrude Mesh node without any math. Just create a n-gone (cylinder) without caps (e.g. by lofting a circle) and then extrude sides and join the result with the lofted n-gon itself just with flipped normals to close back sides of cubes. The result will look exactly same. The only difference will be that the extruded parts and the back sides won't be actually connected and if you connect it by Merge by Distance node it will also weld cubes together. Commented Jan 4, 2023 at 13:14