# hpr value confusion

So ive always been confused with how panda handles the value’s for hpr. Sometimes ill see that when h, p, or r hit 360 it gets set back to 0 again (since thats a full rotation that should be fine)and other times once it hits -180 it will go to 179 (again thats a full rotation(unless im failing at math atm)) what are the values that hpr cannot exceed? at what point do they reset back to 0/180/-180 etc What im confused about is my following code for camera movement around a point

``````if base.win.movePointer(0, base.win.getXSize()/2, base.win.getYSize ()/2):
Pitch = -((pointerY - base.win.getYSize()/2)*.1)

self.camera.pNode.setP(self.camera.pNode, Pitch)

thats run in a task. When i print the pNode’s P value it will go up to 89.99 then start counting down to -89.99 but when i print the hNode’s H value it goes up to 179.99 then back down to -179.99 can i not just keep the hpr value counting up infinitely or just reset at 360?

Hello flips,

I GUESS that has to do with the intention behind the hpr system. The system’s origin can be compared to a person looking straight ahead. Then, rotation simulates the movement of your head.
Pitch means looking up or down. If you exceed the 90 deg. up, the result is the same as looking less far up, but rolling the head by 180 deg and looking behind.

If nothing else helps, I think you can use the rotation matrix of the camera to get rotation.

BR,
Michael

It’s because you are using the relative flavor of setP, setH, etc.–you are setting the rotation of the node relative to itself. This is not a straightforward computation, it’s actually a very complex bit of math going on behind the scenes; and it requires converting your HPR value to a 4x4 matrix, doing work on the matrix, and then converting the 4x4 matrix back into a HPR value.

When this happens, the HPR coordinates get normalized. H and R range between -180 and 180. P ranges from -90 to 90. That’s the way we happened to normalize them; we might have made different choices.

But if you don’t use the relative flavor, if you just do node.setP§, then none of this crazy behind-the-scenes math is necessary, and whatever value you give it remains, even if it exceeds -90 to 90.

David

awesome thank you both for the insight, i have a much better understanding of how hpr and setHpr() work