Math question

Why does

q = Quat()
print q.getForward()



I thought forward would be down the negative Z axis. I know panda’s default camera orientation is forward being +Y, but it seems like this is not sane behaviour for the math lib (ie, I thought the everything was eventually transformed into camera space instead of just altering matrix/quaternion conventions)

Um, for the record, I see:

>>> q = Quat()
>>> q.getForward()
Vec3(0, 1, 0)

which is what I would expect: the default quaternion is identity, and therefore its forward vector is Panda’s default forward vector: the +Y axis.

If you want to return the answer for a different coordinate system, e.g. Z-up, you can ask that too:

>>> q.getForward(CSYupRight)
Vec3(0, 0, -1)

But if you don’t specify the coordinate system you mean, the default is Panda’s default, which is Z-up, and therefore the answer is +Y.

Most people pick one default and use it throughout. Switching back and forth within a single application–e.g. having a Z-up coordinate system for the camera, but a Y-up coordinate system every else–just invites madness. You can, incidentally, change Panda’s default by putting something like this in your Config.prc file:

coordinate-system yup-right

Although caveat emptor: some systems that were built for Panda, e.g. DirectGui, are hardcoded to assume a Z-up coordinate system, and might fail with the new default.


Okay, thanks for your insight. I have an existing application that I’m trying to shoe-horn panda3d into (which assumes -Z forward) and I figured if I did a setLens(0,0,-1,0,0,1) the math would work itself out. It just looks like I need to be more careful when mixing mat/quat conventions.

– John