The ofxAccelerometer.getOrientation() method doesn’t seem to provide a gyro orientation for the Z axis (Yaw?). Is there anyway to retrieve this value?
void updateOrientation()
{
orientation.x = atan2(accelOrientation.y, -accelOrientation.z) * RAD_TO_DEG;
orientation.y = atan2(accelOrientation.x, -accelOrientation.z) * RAD_TO_DEG;
orientation.z = 0;
}
I’ve got a spherical video texture bound to a sphere. I would like to rotate a mobile device to spin around 360º within the sphere. Pitch and Roll work but I just need to get that last value. Any assistance would be appreciated!
Did you manage to get this working? I’m trying to do the same thing…
Thanks
Mark
I ended up using the iOS Gyro class. Camera is an EasyCam. I had drift in the end, but for the most part it worked fine.
(Setup)
motionManager = [[CMMotionManager alloc] init];
motionManager.gyroUpdateInterval = 1.0/60.0;
[motionManager startGyroUpdates];
(Update)
ofVec3f gyro;
gyro.x = motionManager.gyroData.rotationRate.x;
gyro.y = motionManager.gyroData.rotationRate.y;
gyro.z = motionManager.gyroData.rotationRate.z;
roll += (fabs(gyro.z) > .2) ? gyro.z : 0;
pitch += (fabs(gyro.y) > .2) ? gyro.y : 0;
heading += (fabs(gyro.x) > .2) ? gyro.x : 0;
ofQuaternion qr(roll, Znormal); // quat roll.
ofQuaternion qp(pitch, Xnormal); // quat pitch.
ofQuaternion qh(heading, Ynormal); // quat heading or yaw.
ofQuaternion qt; // quat total.
qt = qr * qp * qh;
camera.setTransformMatrix(qt);
Meach
April 9, 2013, 6:12am
#4
Hello,
You should try to do it with the gyro as accelerometers do not feel the rotation around the z axis. So it is just impossible to do that with it.