Posted 5 hours ago
Hello all,
I am sending some geometry pieces back to the origin to do some manipulation. Im using a for loop, and within the loop Ive at least managed to move each piece back to the center. The issue is rotation. I want the objects existing normals “N” to be flush with the x axis while working, and the objects ‘up’ vector to be flush with Y axis {0,1,0}. I know I can use the arccos(dot(up, up2) function to get the angle I need, (and have done so), my issue is I cant figure out how to rotate the pieces accordingly.
So basically–object incorrectly rotated at center– its existing Normals should face towards +x {1,0,0}, and its “up” vector should face towards {0,1,0}.
After work is done, Id like to be able to send the piece back to where it came from, but am a bit stuck.
Thanks for the help!!!
Resetting Object Rotation
5229 1 2- jtk700cln
- Member
- 57 posts
- Joined: 1月 2016
- Offline
- davidderwin
- Member
- 23 posts
- Joined: 3月 2013
- Offline
Using the VEX rotate function on a matrix will work to rotate around a given vector axis. I can't download your file at the moment but if you have a point or object at the origin then run this in a point wrangle:
It will rotate however many degrees (45 degrees in this case) around the vector axis, which in the example above is @side ({0,0,1)}. It sounds like you have calculated the angles that each piece will need to be rotated so by using those angles and changing the vector axis as needed (rotating around x, y or z), this should be able to get your pieces rotated to the desired orientation.
@N = {1,0,0}; v@side = normalize(cross(@N,{0,1,0})); v@up = normalize(cross(@side,@N)); float angle = 45; matrix rot = ident(); rotate(rot, radians(angle), @side); @N *= rot; @up *= rot; @side *= rot; @P *= rot;
It will rotate however many degrees (45 degrees in this case) around the vector axis, which in the example above is @side ({0,0,1)}. It sounds like you have calculated the angles that each piece will need to be rotated so by using those angles and changing the vector axis as needed (rotating around x, y or z), this should be able to get your pieces rotated to the desired orientation.
-
- Quick Links