Jump to content
Developer Wiki and Function Reference Links ×

Finding Polygon Center Point


Recommended Posts

I have been searching high and low for this but have lucked out so far.

I have created a polygon using marionette with a number of variables to control the shape, what I would like to be able to do is "analyse" the resulting polygon and find it's center point.

I realise that this could be a potentially complicated request as depending on the shape of the polygon the center point may not be "on surface" for example a "C" shaped object.

There is also the question of center of planar mass (ie balancing point) or simply center point furthest away from all edges.

For my particular use I am only interested in the "on surface" furthest away from all edges, and I am working with a pretty basic shape.

In my mind it seems quite straight forward, I could definitely find a way to "calculate it mathematically" however it would only work for my specific object so I am sure there is a much better and more versatile solution out there.

Any help would be massively appreciated.

Link to comment
  • Marionette Maven

I'm attaching a file with a node, Centroid2D, I haven't taken the time to handle unit conversions (it appears that the VS function doesn't take them into account) so this node in its current state works with Feet/Inches as document units.

If you're working with millimeters, just take out the "/25.4" in the x and y lines, and if you're working with other units, use the factor to convert from millimeters to whichever other document units you're using.

I'll get around to doing error handling on this at a later time.

Hope this helps!

Link to comment

Hi Marissa & Nic,

1: I thought did the same by 'convert to 3D poly's','get center','locus'. But that doesn't give the same result, I don't understand that.

2: Neither does 'extrude','get gravity center','locus' get the same result???

3: What would be good is to be able to find the largest circle that would fit in a poly and getting the center of that circle.

But I don't know how to solve this.

Link to comment
  • Marionette Maven

I can answer your first two questions quickly, and I'll get to the third one later today after I wake up a bit more :)

1) I'll have to look at Get Center. I don't know who wrote it initially, and I haven't really dove into the logic of it. I think there's a better way to do this anyhow, I'll try to come up with a fix and post it here.

EDIT: I think Get Center works. I'm getting correct results. Can you explain why you think it's incorrect?

2) Get Gravity Center is broken. It's not using the correct function. Again, I'll post it here once I'm sure it's working.

Note on the node once I post it: It probably won't be accurate for Multiple Extrude objects, which is why I haven't already posted it. I've been trying to figure out if I can get it to work for them.

So, for question 3, once I get a better handle on these things, I can hopefully answer this as well for you :)


Attached file with a correct Gravity Center node. NOTE: This node will not work on polys. Use Get Center from the Poly3D category instead.

Edited by MarissaF
Link to comment

As the dutch could say: 'Maybe I've put too much hay on my pitchfork'.

The 2D-center I understand, the middle of the bounding box. The improved gravity-center I understand too. But what is the center of the 'get center' node?

I hope you can answer question 3 in the future. Thanks, almost weekend for me.

Link to comment
  • Marionette Maven

So Get Center works with 3D polys and takes the points at each index in order to get the average value of x, y, and z for each point on the poly.

So say you had a 3D poly with 4 points - (0,0,0), (3,0,0), (3,3,3), and (0,3,3).

The Get Center will average all of the x, y, and z values to create the averaged point, i.e.

x = (0 + 3 + 3 + 0) / 4 = 6/4

y = (0 + 0 + 3 + 3) / 4 = 6/4

z = (0 + 3 + 3 + 0) / 4 = 6/4

(This example is super simplistic and produces boring results...)

With more complex polys, it's possible that the point won't be on a planar piece of the poly at all, since it's just averaging the points. You can kind of think of it as finding where the gravitational center of the poly would be? If that makes any sense?


Edited by MarissaF
Link to comment
  • Marionette Maven


Good point.

I'll see if I can add more logic to this node, I didn't write it originally, but I'll see if there's a way to ignore points that are already on an existing edge and try to modify it.

I didn't even think of that! So big thanks for bringing that situation to my attention!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...