Gimbal Lock
2136 1 0- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
Hi. Vex can transform in global space very well with ‘scale’ and ‘rotate’ functions. Even if scale has something like {1, 0, 1} values. But I can`t extract rotations as eulers from result matrix be cause gimbal lock/ I need euler angles to use it in Edit SOP. So how to prevent fail rotation extraction when scale is 1, 0, 1?
Edited by Alexey Vanzhula - 2016年11月27日 11:06:01
- Alexey Vanzhula
- Member
- 538 posts
- Joined: 12月 2006
- Offline
vector m, M, center, pt_pos; matrix mat, rmat, smat; string pts_str = chs("group"); // GET WORLD TRANSFORM MATRIX mat = getspace("space:current", "space:world"); // GET POINTS ('GROUP' PARM) CENTROID getpointbbox(0, pts_str, m, M); center = ((m+M) / 2) * mat; // MAKE TRANSFORM MATRIX. SCALE BY 'Y' AND ROTATE BY 'X' rmat = ident(); scale(rmat, set(1, ch("s"), 1)); rotate(rmat, radians(ch("r")), {1, 0, 0}); // GET POINTS ARRAY FROM 'GROUP' PARM int pts[] = expandpointgroup(0, pts_str); // TRANSFORM POINTS foreach(int pt; pts) { pt_pos = point(0, "P", pt); pt_pos *= mat; pt_pos -= center; pt_pos *= rmat; pt_pos += center; pt_pos *= invert(mat); setpointattrib(0, "P", pt, pt_pos); }
How to translate this vex functionality (when scale={1,0,1}) to xform sop values: tx, ty, tz, rx, ry, rz, sx, sy, sz, px, py, pz, shear1, shear2, shear3?
Edited by Alexey Vanzhula - 2016年11月28日 12:53:40
-
- Quick Links