Calculating HPR coordinates

Is there a simple way in panda to calculate a heading and pitch based off two coordinates? Basically, I have an arrow starting at one coordinate pointing upwards and I want to make it ‘point’ to the other coordinate. Thanks!

Something like:

arrow.setPos(coordinate1)
arrow.lookAt(coordinate2)

Hpr can be calculated by using getHpr().

Look at the sheet http://www.panda3d.org/manual/index.php/Cheat_Sheets

drwr - thanks. thats what I was looking for.
Would it be possible to use this with controlJoint()?

Say I had 3 fingertips who do not share a parent, but they all share a common grandparent node (palm). could I use lookAt() on the fingertip nodepaths I get from controlJoint() and use lookAt() to make them point to a common point using the grandparent node as a reference node parameter for lookAt()?

Yes, but it’s not as simple as you might think. You have to controlJoint() the finger nodes, and parent the resulting node to the node that you get for exposeJoint() on the parent (not the grandparent) of each finger node. This is necessary because controlJoint() receives a relative transform, and if you want to do global operations on that node you have to have it in the scene graph in the correct coordinate space, which is the coordinate space of the joint’s parent.

So, for each finger joint:

finger1 = actor.controlJoint(None, 'modelRoot', 'finger1')
finger1Parent = actor.exposeJoint(None, 'modelRoot', finger1Parent)
finger1.reparentTo(finger1Parent)
finger.lookAt(whatever)

And now you can use lookAt() to move your finger joint wherever you like. It will rotate the finger joint so that the +Y axis points at the node or point you specify, so you have to model your hand so that’s the right thing to do. There won’t be any constraints, so unless you are careful, the fingers will probably look like their bones are broken.

David

If I wanted to use the grandfather nodepath as the basis for a coordinate system that every finger shares could I do something like this?

finger1 = actor.controlJoint(None, 'modelRoot', 'finger1') 
finger1Parent = actor.exposeJoint(None, 'modelRoot', finger1Parent) 
finger1.reparentTo(finger1Parent) 

finger2 = actor.controlJoint(None, 'modelRoot', 'finger2') 
finger2Parent = actor.exposeJoint(None, 'modelRoot', finger2Parent) 
finger2.reparentTo(finger1Parent) 

finger1.lookAt(grandfathernp, Point3(5,5,5)) 
finger2.lookAt(grandfathernp, Point3(4,6,3) 

That seems reasonable.