# 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

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

• 1

## Create an account

Register a new account