True Center Node

john's Avatar


21 Feb, 2023 02:24 AM

Attached is a new node: true_center. It calculates the true center of regular polygons, stars, and fancy stars.

The centroid node is used to determine the geometric center of a shape in Nodebox. It is based on the the bounds of the shape. But for certain shapes, including regular polygons (generated by the polygon node), stars (generated by the stars node), and fancy stars (generated by my new fancy_star node), with an odd number of sides or tips, the centroid will not return the true center of the shape.

This becomes a problem if you need to rotate the shape or place it precisely. The fewer the sides or tips, the more pronounced the problem is, with triangles being the worst case.

True_center solves this problem. Feed it any regular polygon, star, or fancy star and it will return the ship's true center (the center point where all the corners or tips project from).

See attached screenshot and demo. Hook the output of a fancy_star node, polygon node, or star node to the null node at the top, turn on your origin markers, and render the combine node at the bottom. Since these shapes are all drawn at the origin, their true center (indicated by the red dot), should always be at the origin. As you change the settings and number of sides or tips you will notice that the true center stays fixed. But the centroid, indicated by the smaller black dot, will drift whenever there is arn odd number of sides or tips.

Rotating the shape (around its true center) will not affect the red dot, but will cause the centroid to shift. You can see this easily in the demo by simply hitting the play button.

True_center only works with polygons and stars. In order to find reasonable center points inside arbitrarily weird shapes, see another new node, good_center:

True_center is a life-saver when doing precise work like the Islamic tiles I am working on at the moment. It will be included in the next release of my Cartan Node Library and is free to use with no restrictions.



Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Already uploaded files

  • true_center_screenshot.png 355 KB
  • 15.4 KB

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

17 Jun, 2024 02:26 PM
15 Jun, 2024 01:44 PM
08 Jun, 2024 09:05 AM
08 Jun, 2024 09:00 AM
04 Jun, 2024 04:37 AM