HPR to join two points - trigonometry

Hi,

I have a stick, modeled as a cylinder, aligned by default to the z axis.
I need to place it so its extremities (the centers of the two discs) are located at positions given by 3D coordinates. For instance, it will go from one point at B=(xb,yb,zb) to another at E=(xe,ye,ze).
If I setPos the cylinder in the middle point between B and E and scale it properly, then I guess a smart computation could give the HPR angles do to the job. Is there a standard function for that? Or maybe a trigonometry wizard knows about a set of formulae I could cast?

Thanks for your help!

B.

You can use lookAt instead of setHpr, passing in a custom forward vector of (0, 0, 1), to get the cylinder to align towards a point. Then you can scale it to the right distance.

You can use the global version of the lookAt function if you simply wish to compute the effect as hpr, quat or matrix instead of applying it right away.

Thanks for your answer.
I will try to implement this (I’m new to panda3D, as you might have guessed).

Cheers

B.