 setOrientation() problems

I am trying to keep my camera’s X rotation from going greater than 80 degrees, but the maths involving setOrientation() and getOrientation() are very complex. How would I do this?

Yeah, it’s a nine number matrix. I turned fully east with:
o.setOrientation([(0.0,-1.0,0.0),(1.0,0.0,0.0),(0.0,0.0,1.0)])

fully west with:
o.setOrientation([(0.0,1.0,0.0),(-1.0,0.0,0.0),(0.0,0.0,1.0)])

Notice the last group of 3 numbers is the same in both lists. That’s the z axis.
I think. So why are both the first goup of numbers and the second group of numbers different when only the x axis has changed? Beats me. But I got the numbers by turning it in the direction I wanted and then printing getOrientation(). You have to make sure you don’t change the other axes when you make the move. It’s going to be more complicated for 80 degrees, probably, but you could try a -.8 and a plus .8 where the ones are.

I also found this which might help:

[(cos(a) , -sin(a), 0),
(sin(a) , cos(a), 0),
(0, 0 , 1)]

The a is for angle, but in radians. So you could check to see if the value at sin(a)–[1,0]-- was greater than math.sin(80*math.pi/180)
if it was greater, reset it to the value at 80 degrees.

The camera actuator also has min/max constraints for the x and y planes, which might save a lot of headaches.

Isn’t there an easier way? Or doesn’t someone have code to convert from degrees to euclidian maths? There has to be a simpler way to do this…

Yeah, that would be nice. If you really break it down, it’s not that complicated, but it still seems like a pain. The trouble is you have three axis of rotation. Out of curiosity, I checked around on the net, and a lot of the stuff I couldn’t even understand. If you look at the sin, cos, thing. That’s all dealing with only one angle. To convert your angle to radians you can write function: