Jump to content

Reset Rotation to 0


Kronso

Recommended Posts

Hey all,

I've got a bunch of lines(edges) that and I'd like to be able to rotate them all to be on the same flush axis. I'm trying to break down a poly mesh into it's edges, and bring each edge with it's points back to the origin, and rotate these edges so they are all facing the same direction.  Then use those edges to build on top of, before bringing them back to their original position.

I've been setting up different procedural architecture HDAs for use in my concept art, and I'm trying to make different set ups that take a base grid shape, then uses those dimensions to create buildings.  So far I've only understood enough to work with buildings that have edges that are perfectly set on either their X or Z axis.   I would love to understand a way to work with rotated faces, and I think this would be a perfect solution

I've found Matt Estelas VEX expression to bring objects to the origin and return them, but I don't know how to rotate them flush to the grid.  Any help in doing so would be suuuuper appreciated!

 

Thanks!

Link to comment
Share on other sites

Hey Robby,

you can translate random lines to center by calculating the average of their end points:

image.png.21f35176b14ee4a07b2831c62fae4267.pngimage.png.34071776d0b49df3c624a7e1c26cfde3.png

// translate to origin
vector pos = v@P;
int pt_nb = neighbour(0, @ptnum, 0);
vector pos_nb = point(0, 'P', pt_nb);
vector center = avg(pos, pos_nb);
v@P -= center;

To align them first calculate the direction from one end point to another. Then use the dihedral function to create rotation matrices towards the desired axis.

image.png.34071776d0b49df3c624a7e1c26cfde3.png image.png.4fe679cb30e9b67b486753ea51fa8517.png

vector axis = chv('axis');

// rotate to axis
float neg = sign(pt_nb - @ptnum);
vector dir = normalize(pos_nb - pos) * neg;
matrix3 rot = dihedral(dir, normalize(axis));
v@P *= rot;

That way all lines should point at the same direction:

image.png.61b2e7dc6cf9776f74718641c1c606af.png

center_align_edges.hipnc

  • Like 1
  • Thanks 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...