Local Rotations

   4319   3   1
User Avatar
Member
10 posts
Joined: June 2018
Offline
I am trying to rotate connected primitives on their local axis using vex. I've got the matrix and the the radians set up, just not sure i understand how to tell it to rotate it each connected primitive using their own pivot. It seems like it is still using the pivot at the origin. Adding my file as well.
float angle = radians(chf("Angle"));
vector dir = chv("Direction");
matrix3 m = ident();
string grp;

for (int i=0; i< i@class; i++)
{
    
    grp = '\@class='+itoa(i);
    rotate(m, angle, dir);  
    // apply the rotation
    @P *= m;
}

Image Not Found



Edited by raparicio0 - Dec. 6, 2018 03:09:39

Attachments:
localRotations.hiplc (109.0 KB)
localRotations.JPG (87.5 KB)

User Avatar
Member
359 posts
Joined: April 2017
Offline
Rotations like this using a 3x3 matrix don't have any inherent notion of a “pivot”. If you want them to rotate from their respective centers, what you need to do is figure out what that center point is first (getbbox_center() will help here), then move all your points so that that center point is at the origin (@P -= center), THEN do your matrix multiplication to @P, THEN move the pivot back to its original position in space (@P += center).
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
475 posts
Joined: July 2005
Offline
Hi,

Rotations are always made around the origin. If you want to rotate your geometry around another point, you have subtract the point first (so this point will be the origin (0,0,0)), after that you can perform your rotation and then you have to add the point position to the rotated geometry (to move it back to the former position). For each class you have to define a pivot point first. I think a good way is taking the average over all point from each class.
Edited by Aizatulin - Dec. 7, 2018 12:25:12

Attachments:
localRotationsX.hipnc (118.2 KB)

User Avatar
Member
10 posts
Joined: June 2018
Offline
Thank you so much! This helps me further understand this concept!
  • Quick Links