Calculating forward vector from HPR

I need to calculate the vector pointing forward out the nose of my node, given its HPR.

Wikipedia on Yaw, pitch, and roll seems to explain the necessary math, but it would take me several hours of review to understand it, and to figure out how to do the matrix multiplications in Panda. I figure this problem is so basic that someone here must have a solution handy that they can paste at me.

Thanks very much.

hi and welcome to panda :slight_smile:

good news first: usualy you dont need to mess with anything related to matrix manipulations, fancy vectormath or even sine/cos or triangulation in general.panda provides tons of easy to use convenience-functions you can use instead.

btw. the vector pointing in front of your model would be (1,0,0) or depending on the axis-system you use maybe 0,1,0 or 0,0,1. (that’s relative to the model’s node itself, you can easily translate those to other coordinate systems,too)

if you describe what you want to do we might be able to show you how to do it the “easy” way using panda’s high-level-functions.


get (0,1,0) (panda3d’s forward) of node in render’s coordinate system

if you dont have a node for hpr create one

node = NodePath("tmp")

Thank you both for the warm welcome.

getRelativeVector is just what I was looking for. I searched through the API documentation, thinking Panda must have a convenience method for this, but using getRelativeVector in that way didn’t occur to me.

Hopefully before long I’ll have a space shooter to show you.

Hey, thanks, I was looking for that yesterday, too. :slight_smile:

Is there anywhere I can find out what vector/math functions Panda defines? I’ve poked around with the dicts for various classes, like Vec3, etc, but I’m curious where specifically all of this gets defined in the C++ code?