- Home /
Comparing quaternion values and extracting values from quaternions
I'm making a gyroscope (and I think that I might need accelerometer too) based game for mobile devices.
I want to compare quaternions and their values to other values. When player wishes to start playing he has to calibrate the game and the game then sets calibration for the RotationWhenCalibrated Quaternion.
Correct me if I'm wrong, but I believe that attitude is the rotation of the device as a quaternion.
Assuming I'm right what I want to achieve is to be able to rotate Camera with the difference between Input.gyro.attitude in Update() and rotation at last frame but only if the difference on X and Y axes are less than defined constant float values. (e.g. maxXrotation = 30f, maxYrotation = 20f). I also want to extract rotation difference in float on certain axes to calculate different gameplay related powers. If I use EulerAngles I will have problems when the value jumps from 359 to 0.
If possible (not necessary) post example code in C#