3
$\begingroup$

example 1

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.

node tree basic problem to solve

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.

$\endgroup$
6
  • 2
    $\begingroup$ You should give the question a meaningful title that reflects what your question is actually about. $\endgroup$ Commented Jan 4, 2023 at 8:40
  • $\begingroup$ not sure how to word it i'll try $\endgroup$ Commented Jan 4, 2023 at 8:44
  • 3
    $\begingroup$ 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 $\endgroup$
    – Gorgious
    Commented Jan 4, 2023 at 9:02
  • $\begingroup$ 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. $\endgroup$ Commented Jan 4, 2023 at 9:59
  • $\begingroup$ 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 $\endgroup$
    – Boidot
    Commented Jan 4, 2023 at 10:09

2 Answers 2

5
$\begingroup$

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

enter image description here

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)$:

enter image description here

Both methods demonstrated here:

$\endgroup$
2
  • $\begingroup$ @quellenform :D ... I must learn my MathJax! In the mean time, it seems I can rely on the gang.... $\endgroup$
    – Robin Betts
    Commented Jan 4, 2023 at 11:45
  • 1
    $\begingroup$ ...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/… $\endgroup$
    – quellenform
    Commented Jan 4, 2023 at 11:48
3
$\begingroup$

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

enter image description here

…and in blender:

enter image description here

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

enter image description here

Entire solution:

enter image description here

$\endgroup$
5
  • $\begingroup$ Seems I wasn't fast enough :D $\endgroup$
    – Vajtus
    Commented Jan 4, 2023 at 12:12
  • $\begingroup$ +1 ... that's because you were so much more thorough than me. Nicely illustrated :) $\endgroup$
    – Robin Betts
    Commented Jan 4, 2023 at 12:14
  • 1
    $\begingroup$ Speed does not always count here. The quality of the answers is crucial! Thank you for your contribution! $\endgroup$
    – quellenform
    Commented Jan 4, 2023 at 12:15
  • $\begingroup$ between the two of you I think I got it working. Thanks Robin Betts & Vajtus. $\endgroup$ Commented Jan 4, 2023 at 12:18
  • $\begingroup$ @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. $\endgroup$
    – Vajtus
    Commented Jan 4, 2023 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .