Kronso Posted October 5, 2019 Share Posted October 5, 2019 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! Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 5, 2019 Share Posted October 5, 2019 Hey Robby, you can translate random lines to center by calculating the average of their end points: // 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. 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: center_align_edges.hipnc 1 1 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted October 5, 2019 Share Posted October 5, 2019 Alternatively, if it's really just a set of lines, you could put any other point to its primitive's perimeter: float perim = primintrinsic(0, 'measuredperimeter', @primnum); v@P = @ptnum % 2 ? set(0.0, 0.0, perim) : vector(0.0); center_align_edges_2.hipnc 1 Quote Link to comment Share on other sites More sharing options...
Kronso Posted October 6, 2019 Author Share Posted October 6, 2019 Thanks so much again, Konstantin! The images and directions there are super helpful. Appreciate the help a ton, this is going to be extremely useful! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.