rdg Posted June 5, 2007 Share Posted June 5, 2007 I must admit that I have a dangerous smattering of quaternions. But I also have a function that returns a quaternion. Houdini offers this transformAxisSOP - is this the place where my quaternion should go? The make this even more complicated - I think I need to calculate the area for my quaternion In my other program I *just* tell the object to be controlled by quaternions - now I am looking for the equivalent in Houdini ... This is my function - not yet houdinized: fn getrot t = ( if t<=0f then return quat 0 0 0 1 -- we assume at t=0 obj is aligned with the world t0 = t-1 -- previous frame time t1 = t -- current time rot0 = getrot(t0) -- get the rotation in the previous frame recursively p0 = at time t0 obj.position -- previous position p1 = at time t1 obj.position -- current position if(p0==p1) then return rot0 -- if no distance is traveled, rotation is the same as previous frame dif = p1-p0 -- difference in positions len = Length(dif) -- distance that's traveled vec = dif / len -- normalized movement vector. r0 = r1 = 20 -- radius rotax = cross vec [0, 0, 1] -- rotation axis angle = 180*len/((r0+r1)) -- rotation amount (in degrees) rotdif = quat angle rotax -- Quaternion which defines rotation from t0 to t1 rot1 = rot0 + rotdif -- final rotation ) getrot(currentTime) It takes the object position at $F and ($F - 1). Calculates the distance traveled and constucts a quaternion that represents the rotation the object needs to reach that point. If this works - one can move a object and it starts "rolling" by itself. As my object is a cube I should maybe post this in the "rolling cubes" thread? Georg Quote Link to comment Share on other sites More sharing options...
doc Posted June 5, 2007 Share Posted June 5, 2007 Well I'm just pulling this out of my ass, but have a look at the attached file (the vop net specifically), let me know if it helps. L quaternion_rot.hip Quote Link to comment Share on other sites More sharing options...
rdg Posted June 6, 2007 Author Share Posted June 6, 2007 (edited) let me know if it This is a step in the right direction and helps me to define my question. The VOPnetwork you posted is the rotation part of the transformAxisSOP? I now know that my first question has to be: How can I define and calculate quaternion using the expression language and access its components? vector someQuat(){ some = vector4(1, 2, 3, 4); return some; } sadly someQuat()[0] to someQuat()[3] returns always 1. Writing this I realize that there is a recursion in my function that sure will lead to a: Unable to evaluate expression (Expression recursion too deep) I will skip this topic for now. It took me 5 years to collect and parse all the information to be able to build a rolling cube rig in max. Why should I be able to redo this with a program I know for 6 months? Georg Edited June 6, 2007 by rdg Quote Link to comment Share on other sites More sharing options...
doc Posted June 6, 2007 Share Posted June 6, 2007 The VOPnetwork you posted is the rotation part of the transformAxisSOP? No, the vop network has nothing to do with the transformAxisSOP. Here's what's happening in the vopnet (dive inside it and have a look): I start by using a user defined angle and axis to plug into the quaternion vop. this gives me my quaternion value, which I change into a matrix and then multiply by P. This gives me the new rotated position of the cube. you don't have to define the quaternions with the quaternion vop like I did, this was just the easiest way for me to define a quaternion. You can define your quaternion value eslewhere, stuff it into an attribute and then have that attribute feed into the "quaternion to matrix3" vop How can I define and calculate quaternion using the expression language and access its components? So you want to do this in hscript instead of vex? If so is there a particular reason for wanting to do it in hscript instead of vex? Vex is going to be much faster and much easier to use. Not sure I completely understand what you're after, but I hope this helps. L Quote Link to comment Share on other sites More sharing options...
rdg Posted June 18, 2007 Author Share Posted June 18, 2007 Not sure I completely understand what you're after, but I hope this helps. I am sorry I missed your answer - I should start subscribing my own threads ... I've been on holidays. But I will take another look at your network now you explained it. I am not targeted specifically at hscript and currently I play a lot with matrix values in vex and try to 're engineer' what they do ... Wolfwood explained me that attribute approach here: http://www.sidefx.com/index.php?option=com...p;p=40090#40090 This and your reply explains how to calculate a quaternion value and use one of its components. What I am after: I want to transfer this maxscript function to houdini. Iit calculates the distance between the object now and the object 1 frame in the past. The cross product of this vector and [0, 1, 0] (in houdini) should give me the rotation axis. The angle is calculated and a quaternion value is created. This value is added to the rotation of the previous frame. I set a keyframe at frame 0 and other keyframes with new positions. The effect is a object that "rolls" based on its positional change. Georg PS: I now subscribed to this thread - sorry again. Quote Link to comment Share on other sites More sharing options...
rdg Posted June 18, 2007 Author Share Posted June 18, 2007 http://proforma.preset.de/cgtalk/rdg-rc/rdg-rolling_cube.mp4 [1] This is a screencapture of the result of the maxscript. Now that I am trying to get more and more "houdinized" I want to rebuild it in houdini as well. That's what I am after. [1] http://www.preset.de/2007/0525/rollingcube/ [2] http://www.preset.de/2007/0530/rollingcube/ Quote Link to comment Share on other sites More sharing options...
edward Posted June 19, 2007 Share Posted June 19, 2007 I was gonna say to look at the files in this thread: http://forums.odforce.net/index.php?showtopic=95 However, it seems that all the old attachments there are gone now? Marc? Quote Link to comment Share on other sites More sharing options...
rdg Posted June 19, 2007 Author Share Posted June 19, 2007 yeah they are gone. I looked at some of them in my very houdini begining. maybe I have kept some of them. But if I remember well, those cubes just rolled in one direction. I managed to to get the cube rolling in one direction back and forth. I will search for this file later. The problem arises if the cube should change the direction. Georg Quote Link to comment Share on other sites More sharing options...
rdg Posted June 19, 2007 Author Share Posted June 19, 2007 as promised here is the file. sometimes this houdini is too *easy* for my complexificating brain. No quaternions needed. Preparing the monodirectional version for upload I was thinking maybe I just need to split the rotation in its components. Voila. Being a scientist in my dreams I should see if this approach would be possible with max, too. Yeah, the cube is sliding. I would interpret this "character" - to me the cube looks *flaunty(??)*. A sinusoidal interpolation should fix this. Georg rdg_rcr2.hipnc Quote Link to comment Share on other sites More sharing options...
Marc Posted June 19, 2007 Share Posted June 19, 2007 All the attachments work for me... could you point me to one that's broken? Thanks Marc Quote Link to comment Share on other sites More sharing options...
edward Posted June 20, 2007 Share Posted June 20, 2007 This one? http://forums.odforce.net/index.php?act=at...post&id=484 Actually, I read the error message more closely this time and it looks like a permission problem? Quote Link to comment Share on other sites More sharing options...
Marc Posted June 20, 2007 Share Posted June 20, 2007 yeah weird... it shows up perfectly for me. I'll log out and try again. ok, got it. There are new permissions in the new forum version and some of the forums have the 'download' permission disabled. If you notice it in any other forums then please let me know. Thanks Marc Quote Link to comment Share on other sites More sharing options...
rdg Posted June 21, 2007 Author Share Posted June 21, 2007 the file I posted just looks right - but it doesn't work for arbitrary movements. It looks like: No Quaternions - no rolling stuff ... In the following file I tried to rebuild the above formula with spare channels and a chop network. It looks promising but: # I haven't found a way to manipulate vector data in chops like cross products and/or quaternions. # I am sure there is another error in resoning. # I guess I need to experiment/learn the coherences between quaternions and matrixes. Georg setup_17.hipnc 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.