From: Kailas N. <ka...@my...> - 2008-02-05 21:52:59
|
Hi! I'm working on a program in visual python and am running into a weird problem (maybe it's my own user error, but I can't see what I'm doing wrong) To run the attached code, need wxpython installed too. In my code, I've got a "human body" constructed using some primitive blocks, cylinders, etc. I want to be able to model upper torso movement, as well as arm movement that's recorded by some sensors placed around the body. The arm movement works great, and I can easily control the position and rotation of the upper arm and elbow (all that I'm interested in). The torso is behaving a bit strangely. I have a Box object I create: Chest = box ( pos=(0,HeadDiameter+SegmentSpace+HeadDiameter/2,0), axis=(2*HeadDiameter,0,0), width=.75, height=HeadDiameter, length=2*HeadDiameter, color=color.red) And based on the "pitch", "yaw" and "heading" angles, I can rotate it. When the chest pitches forward, it needs to rotate about the line that goes through the gap between the torso and stomach, so I do the rotations with the vectors, moving the position of the chest block, as well as rotating it. (I actually tried the Rotate function for the block itself with no success) #(utp=pitch, uth=heading, uty=yaw) cloc=UTOrigin+rotate(UTUnitAxis,utp,(1,0,0))*HeadDiameter/2 caxis=rotate( (HeadDiameter*2,0,0), utp,(1,0,0) ) #### !!!! Why doesn't this make the check pitch forward? caxis=rotate(caxis,uty,(0,0,1)) caxis=rotate(caxis,uth,(0,1,0)) Chest.pos=cloc Chest.axis=caxis As you can see from the code, for some reason the rotation that's supposed to happen about the long axis of the box doesn't. the strange thing is that the other ones work ok, so I'm not sure what I'm doing wrong. I've attached the code if you want to try and run it. The problem is on line 48. You'll notice that the arm doesn't follow the torso just yet, which is ok. Any ideas? Thanks! -kailas |