# "The Orange Problem"

Like most of you are aware the axis orientation of Panda is setup using Heading, Pitch and Roll. Using just Heading and Pitch any direction is possible in 3D space.

So you can imagine a Sphere with Heading as longitudinal lines and Pitch as latitude lines starting with 0 and going to 90 at the north pole, -90 at the south pole.

The problem here is that as one approaches pitch of 90 or -90 the 360 of heading is a smaller circle than it was at the equator.

Usually this is no big deal but, I now want to use panda’s HPR system to steer a vehicle in 3D space. I modify heading and pitch independantly but as pitch goes to 90 degrees, any modification of heading moves the craft in a tight circle.

The system is set up the way an orange is. The segments are thick in the middle and peak at the ends.

I would like a system were the user who is steering is oblivious to the orange system. Where left is aways left and right,-right, up aways up. etc. no matter what the orientation of the object was before the user started steering.

Anyone have a solution to this?

Here’s what I’ve tried (aka. here’s what didn’t work)

I put a dummy node out in front, a child to the steered object. When the user turned left, the dummy node still in front of the steered object moved to the left.

Then two commands were issued in this order:

1. the steered object was placed where the dummy was.
2)the steered object then looked at the dummy.

I tried various variations of this but it didn’t help.

I’d greatly appreciate any help. I hope I’ve explained the problem properly.

I’ve not used them myself, but I think you are looking for quaternions.

Actually, I think you just want to apply a rotation relative to the object’s current position. To apply a relative rotation of h, instead of doing this:

``object.setHpr(object.getH() + h, object.getP(), object.getR())``

do this:

``object.setHpr(object, h, 0, 0)``

This means to rotate the object to an additional (h, 0, 0), relative to the orientation it had previously.

David

LOL
This SO reminds me of myself. I asked the same question when I first came here. And drwr gave me the same answer, too.

Anyway, if you’re trying to write something similar to a space shooter (like a flight sim) you might want to have a look at my code.
You can find it in the Showcase section.

It has complete movement in 3D space, multiplayer networking, collision detection, some uses for the particle engine, shader, lightning, sound…
It has even implemented a radar (a problem which occured more than once on the forums was how to implement one, it’s really simple tough).

thanks drwr, worked great.

That saves me a lot of headaches.