hi,
This is probably a really easy question for some folk, but I would really appreciate any illumination in my attempts to get more math savy.
I want to work out how the calculate rotation values for an object via points, ideally in VOPS, just out of interest.
I drop a box in DOPS onto a groundplane and it falls, rotates around a bit, then settles. I want to go back to SOP level, make a point at the original object centroid, then add attributes to that new point that describe xyz position and rotation animation, so that when I copy a box to the point, it exactly matches the DOP animation.
Of course, DOP gives you all that information, or I could parent it, but I want to extract the transforms from the cached animation just as an exercise to get a grip on things like vector calculations, polyframe, matrices, etc.,
So, I have my point at the centroid, I can reference any point on the cube corners to produce a vector (two points) that I can see visually rotationing in the viewer with an addSop, but how do you go about then calculating a rotational angle from that, which could be applied to any object to match the cached animation? Would a lookAt node in VOP between the two workout? Or maybe bit of trig functions in an attribute field, reference one point from the other?
I know this is really easy for some folk, please give my ‘journey’ in vector math a boost
thank you!!!!!!!
how to calculate rotation vector values - self-learning
27384 5 4- frankvw
- Member
- 61 posts
- Joined: Feb. 2006
- Offline
- frankvw
- Member
- 61 posts
- Joined: Feb. 2006
- Offline
So here is an hipnc that has a DOP animated box, then the original static box with a rotation vector made with a lineSOP, from the box centroid to one of the edges. You can see the vector line staying in step perfectly with the edge to show the rotation - the copSop is just used for illustration purposes.
What I am trying to better understand is how I can take that rotation vector and apply it to the static box so the DOP animation and extracted transforms onto the static box will perfectly match.
I'd like to try and work out a way to extract the transform matrices in VOPs (lookAT VOP? that seems to do this but couldn't get it to workout) and also via some attribute vex trig functions/expressions that I could then plug into a transform paramaters.
Maybe a sidefx developer could cast an eye? I think its a useful example exercise for artists trying to read up on vector math and to get a better feeling for practical application of vector math in houdini.
thanks again!!!
What I am trying to better understand is how I can take that rotation vector and apply it to the static box so the DOP animation and extracted transforms onto the static box will perfectly match.
I'd like to try and work out a way to extract the transform matrices in VOPs (lookAT VOP? that seems to do this but couldn't get it to workout) and also via some attribute vex trig functions/expressions that I could then plug into a transform paramaters.
Maybe a sidefx developer could cast an eye? I think its a useful example exercise for artists trying to read up on vector math and to get a better feeling for practical application of vector math in houdini.
thanks again!!!
- frankvw
- Member
- 61 posts
- Joined: Feb. 2006
- Offline
hi again,
Hummm … getting closer. I looked into the vangle expression function, plugged that into an attribute node, then put it into a transform rot parms. I thought it returned radians but values pretty much return something that looks nearly right as degree values, pretty close except it kinda wobbles a bit like ‘gimble’ thing here and there,
making a vangle between the lineSOP rotation vector and vector3(1,0,0), vector3(0,1,0), vector3(0,0,1) xyz axis each in turn.
The exhelp says ;
vangle(a, b) will return the same result as acos ( dot (normalize(a),
normalize(b)) ). It will not produce a negative result because the dot
product is symmetric, and does not take the order of a and b into
consideration.
You can define a turning order with the left hand rule or something
similar.
Try the following expression to get a signed result:
sign(dot(cross(cross(a,b),b),a)) * vangle(a,b)
Maybe explains the little difference. Have to look into defining the left hand rule thingy there. The “sign(dot(cross(cross(a,b),b),a)) * vangle(a,b)” didn't work out as well as the vangle here. Of course, origin or vrorigin in a pointSOP work perfectly, but that is doing all the vector math for you, so not much of a learning experience that way.
Looks like Chris Maynard at CMIVFX made some DVD's covering vector math in houdini some time ago, have to get the credit card out I guess and see if that illuminates any.
Hummm … getting closer. I looked into the vangle expression function, plugged that into an attribute node, then put it into a transform rot parms. I thought it returned radians but values pretty much return something that looks nearly right as degree values, pretty close except it kinda wobbles a bit like ‘gimble’ thing here and there,
making a vangle between the lineSOP rotation vector and vector3(1,0,0), vector3(0,1,0), vector3(0,0,1) xyz axis each in turn.
The exhelp says ;
vangle(a, b) will return the same result as acos ( dot (normalize(a),
normalize(b)) ). It will not produce a negative result because the dot
product is symmetric, and does not take the order of a and b into
consideration.
You can define a turning order with the left hand rule or something
similar.
Try the following expression to get a signed result:
sign(dot(cross(cross(a,b),b),a)) * vangle(a,b)
Maybe explains the little difference. Have to look into defining the left hand rule thingy there. The “sign(dot(cross(cross(a,b),b),a)) * vangle(a,b)” didn't work out as well as the vangle here. Of course, origin or vrorigin in a pointSOP work perfectly, but that is doing all the vector math for you, so not much of a learning experience that way.
Looks like Chris Maynard at CMIVFX made some DVD's covering vector math in houdini some time ago, have to get the credit card out I guess and see if that illuminates any.
- brianBurke
- Member
- 192 posts
- Joined: Nov. 2008
- Offline
the attribute reorient sop can do the ‘hard work’ for you. it works by taking some vectors on rest geometry and ‘reorienting’ them according to an animated mesh. in this example, i'm just making the axises (x, y, z) and reorienting them to follow the animated mesh.
the only other thing to consider is that a single vector isn't enough to represent a rotation. often people use a normal and an ‘up vector’, but if you have these two, you're only a cross product away from having a full rotation matrix (3 vectors perpendicular to each other is a rotation matrix).
this example shows how to use attrib reorient to make a rotation matrix. it then uses this matrix to extract euiler angles (rx ry rz) for object level, and also a quaternion ‘orient’ attribute for the copy sop.
congrats for progressing on learning this stuff, understanding the fundamentals opens up new worlds with cg.
the only other thing to consider is that a single vector isn't enough to represent a rotation. often people use a normal and an ‘up vector’, but if you have these two, you're only a cross product away from having a full rotation matrix (3 vectors perpendicular to each other is a rotation matrix).
this example shows how to use attrib reorient to make a rotation matrix. it then uses this matrix to extract euiler angles (rx ry rz) for object level, and also a quaternion ‘orient’ attribute for the copy sop.
congrats for progressing on learning this stuff, understanding the fundamentals opens up new worlds with cg.
- frankvw
- Member
- 61 posts
- Joined: Feb. 2006
- Offline
hi!
Thanks for that, I see how that reorient helps out for this. I've been looking into quaternions and matirices in VOPS as well. And been reading a book on vector math, something I thought I would never do again at high school! I've actually been using houdini for years but my background has been entirely fine art and I've always been able to achieve most things I ever need just with basic nodes - a ray of hope there to any artist out there who thinks houdini is just for math gurus! After a while you just kinda get more and more curious about what happens under the bonnet and houdini makes it easy to dip a toe deeper if you want. I bought the chris maynard vex things as well, they are really helpfull also.
cheers!!!!
Thanks for that, I see how that reorient helps out for this. I've been looking into quaternions and matirices in VOPS as well. And been reading a book on vector math, something I thought I would never do again at high school! I've actually been using houdini for years but my background has been entirely fine art and I've always been able to achieve most things I ever need just with basic nodes - a ray of hope there to any artist out there who thinks houdini is just for math gurus! After a while you just kinda get more and more curious about what happens under the bonnet and houdini makes it easy to dip a toe deeper if you want. I bought the chris maynard vex things as well, they are really helpfull also.
cheers!!!!
- Alejandro Echeverry
- Member
- 691 posts
- Joined: June 2006
- Offline
Thanks Brian, very useful example!!!
Feel The Knowledge, Kiss The Goat!!!
http://www.linkedin.com/in/alejandroecheverry [linkedin.com]
http://vimeo.com/lordpazuzu/videos [vimeo.com]
http://www.linkedin.com/in/alejandroecheverry [linkedin.com]
http://vimeo.com/lordpazuzu/videos [vimeo.com]
-
- Quick Links