(Panda3d uses the right-handed system and calls the Y+ axis “forward”, Z+ axis “up”, and X+ axis as “right”. While this is purely arbitrary, understanding this is necessary in order for my examples to work as you might expect.)
Rotations in HPR are built from three separate axis, all mutually perpendicular from each other – This is the very nature of what Euler rotations are. But you can also work in other representations, such as quaternions or even manipulate the direct matrix representation itself. HPR is a merely a convenient method for referring to an object’s orientation, either relative or absolutely.
If you do getHpr(), you are requesting the object’s local rotation in HPR. Heading will indeed reflect which way the object is pointing along its up axis. But if you use getHpr(render), then it will be that object’s rotation but expressed in world space. Now, the heading will reflect how that object is pointing in WORLD coordinates. The up axis will be Z+ in the world. Rotations are just like Cartesian coordinates, they are relative.
Not that getHpr()/getHpr(render) will be the same if the object is directly parented to render, so it will always be in world space. If you get a little confused, the best way to make the math simpler is to temporarily work in world coordinates and then convert back to local space. (Most Panda3d functions can do this implicitly, by giving it a reference frame, such as my getHpr(render) example above.)
Your trig is the raw math behind a singular Euler axis. The A is the unit vector describing that rotation’s axis. You can convert HPR into a unit sphere at any time, though I don’t believe Panda3d has helper functions to do that directly from a HPR. You can, however, do so from a Quaternion:
quat = object.getQuat() # local rotation
forward = quad.getForward()
up = quat.getUp()
right = quat.getRight()
As for your Projectile examine – If I am understanding right, you want to calculate a direction that will act as the end point for a ProjectileInterval, but only pointed for 2 units worth of distance from the front of MyObject.
getRelativePoint() is a really handy function. It allows you to return points from one coordinate space in another. Birukoff’s example demonstrates how you can use it to find a relative point that is 2 units ahead of the forward vector of your origin object.
You could also do the math as such:
fwd = self.myObject.getQuat().getForward()
endPos = self.myObject.getPos() + fwd * 2.0
self.trajectory = self.myObject.posInterval(endPos=endPos, duration=1)
But, as you can see, getRelativePoint() saves wear and tear on your fingers and is cleaner to read.