Measure size of geometry for every axis

   4670   4   1
User Avatar
Member
25 posts
Joined: Nov. 2016
Offline
My goal is to uniformly scale down any input geometry so it fits in a 1x1x1 box.
For this I need to find a way to measure the size of the geometry for each axis, see in which axis it has the largest size and finally scale this down to one (by dividing it) and scaling the rest down by the same value.

Can anyone help me with the measuring?

Cheers!
User Avatar
Member
107 posts
Joined:
Offline
Hello aarondornez,

I've made a preset for doing this for my transform nodes. Basically here is what I put in my various fields:

In translate: -$CEX, -$CEY, -$CEZ

In scale, in all fields: 1/max(max($SIZEX,$SIZEY), $SIZEZ)

In pivot: $CEX, $CEY, $CEZ


This should scale any geometry to unit size and center it at the origin of your scene.

Cheers,
Dag
User Avatar
Staff
6818 posts
Joined: July 2005
Offline
There is also the Match Size SOP. By default it goes to a 1x1x1 box centered at the origin. It is also an HDA, so you can dive in and see how it works.
User Avatar
Member
25 posts
Joined: Nov. 2016
Offline
Thank you for the response, the transform approach is really clever and simple and definitely one I need to remember! The Match Size Sop didn't really keep the uniform scale as I wanted but I see some use for this node in my project so thanks again!
User Avatar
Member
721 posts
Joined: Sept. 2013
Offline
In order to scale any object proportionally to unit size, you can also put this into a point wrangle:

float max_size = max( getbbox_size(0) );
@P *= 1.0 / max_size;
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
  • Quick Links