Jump to content

Rotate to have the largest face/primitive down


Recommended Posts

I'm running a for-each-connected loop, and need to rotate separate shape such that the largest face is down, for example the one marked L is the largest for the shape in the image.

I have a theoretical idea, no clue how to implement it, and not sure if there is a faster or simpler way:

(1) get the largest face (no idea how)

(2) rotate till the normal of the largest face is facing down

Again it's too theoretical, but if you have a way that would turn these flat on they largest face I'll be grateful

 

largest face down.JPG

Link to comment
Share on other sites

This isn't too bad. What you want to do is, for each piece:

  1. measure the area of all primitives
  2. find the largest primitive (sort by area)
  3. compute the primitive normal
  4. use dihedral() to compute the matrix that rotates that primitive normal to face {0,-1,0}
  5. multiply all points in the piece by that matrix

I'm attaching an example file.

point_pieces_down_toadstorm.hip

  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...