quaternions

How to enable gyroscope camera at current device orientation

微笑、不失礼 提交于 2019-12-17 16:54:19
问题 I would like to enable gyro controlled camera onButtonClick event but I want it to start at the camera's current position. Currently when the gyro gets enabled it moves the camera off to a new position (probably the devices current gyro rotation) rather than leaving it where it is and gyro-ing from that point. Hope I'm making sense, but basically I don't want the user to notice any change in what they are seeing in the game (ie. camera controlled by gyro but not that user would notice that

Using quaternion instead of roll, pitch and yaw to track device motion

点点圈 提交于 2019-12-17 15:52:05
问题 Please bear with my long question, I am trying to make it as clear as possible. What i am trying to do is, get the attitude(roll pitch and yaw) when a picture is taken using camera and then save the attitude values to nsuserdefaults. After saving, the orientation is changed and then try to bring the phone to the same attitude the picture was taken by constantly comparing the attitude values(saved and current). For the purpose of interface, the user interface has 3 dots (one for each attitude

Convert Quaternion rotation to rotation matrix?

落花浮王杯 提交于 2019-12-17 09:30:53
问题 Basically, given a quaterion (qx, qy, qz, qw)... How can i convert that to an OpenGL rotation matrix? I'm also interested in which matrix row is "Up", "Right", "Forward" etc... I have a camera rotation in quaternion that I need in vectors... 回答1: The following code is based on a quaternion (qw, qx, qy, qz), where the order is based on the Boost quaternions: boost::math::quaternion<float> quaternion; float qw = quaternion.R_component_1(); float qx = quaternion.R_component_2(); float qy =

Rotate 3D Euler point using Quaternions to avoid gimbal lock

谁都会走 提交于 2019-12-13 05:18:20
问题 Firstly, I have done much googling and checking other stackoverflow posts about this, but cannot get a working reply or a snippet of working code. Maths is not my strength. I need to have a routine that takes a camera point (CX,CY,CZ) and rotate it about a lookat point (LX,LY,LZ) by three rotation angles (RX,RY,RZ). Using euler rotations leads to gimbal lock in some cases which I need to avoid. So I heard about using quaternions. I found this to convert the rotations into a quaternion http:/

Java code to get rotation angle around an axis from quaternion

十年热恋 提交于 2019-12-13 02:06:44
问题 I am really struggeling to find the correct way to get the rotation angle around a single axis from an arbitrary quaternion. So other words I want to find the portion of the expressed rotation around a specified axis (in my case the Z-axis of the coordinate system, but an arbitrary solution would be nice) in terms of the angle. Can anyone point out to achieve this? Ideally some java fragment would be nice. I tried the solution proposed in 1 for attitude, which is: asin(2*qx*qy + 2*qz*qw)

How to rotate a camera view in OpenGL 2.0 ES

半城伤御伤魂 提交于 2019-12-13 01:28:48
问题 I want to make a 360-world using OpenGL 2.0 ES on Smart phone. And I want to make camera view follow the Smart phone Sensor using a quaternion , like an youtube 360 video or an Oculus. I get a Quarternion value using public void setquaternion(...) Function. I change the Quarternion values to 4x4 rotate matrix using makeRotateMatrix() function. How can I control the camera view using this matrixes....?(moving camera's sight) I'm getting hard time because of this... please help me..... ;( And

Solving for calibration quaternion

依然范特西╮ 提交于 2019-12-12 23:19:31
问题 I'm writing an Android app that requires the rotation vector. I'd like to use the TYPE_ROTATION_VECTOR but in some of my test devices the magnetometer doesn't perform well to say the least. Instead, the TYPE_GAME_ROTATION_VECTOR provides much smoother data (but I can't get direction relative to the Earth). What I ended up doing is while my data is loading, I run both virtual sensors. I now have an average quaternion for both, call them R ( TYPE_ROTATION_VECTOR ) and R g ( TYPE_GAME_ROTATION

Quaternion Camera Representation in 6DOF - fending off inherent rolling

走远了吗. 提交于 2019-12-12 23:16:05
问题 first question on SO although I've been here many times through Google. I have read quite a lot on the topic of using quaternions to represent rotation as well as finding people who have similar problems. I have yet to find a good solution, or one that I could understand.. so I'm giving a shot at asking a clear enough question to generate solid answers. I am currently using a quaternion (specifically, a Qt 4.7 quaternion/C++) to represent the orientation of my camera. At each step of the

Quaternion from Orthogonal Basis

可紊 提交于 2019-12-12 10:53:55
问题 I have a projectile object that is moving along a velocity vector. I need to ensure that the object is always facing in the direction of the velocity vector. Furthermore, I am representing object rotation using quaternions, not matrices. I know that the first step is to find an orthogonal basis: forward = direction of velocity vector up = vector.new(0, 1, 0) right = cross(up, forward) up = cross(forward, right) How might I convert the basis into a rotation quaternion? Solution Note, I'd like

Converting a direction vector to a quaternion rotation

淺唱寂寞╮ 提交于 2019-12-12 07:51:37
问题 I can find a ton of questions about turning a quaternion into a direction vector but none for the other way around which makes me think I'm doing something wrong, but bear with me. What I'm trying to do is simply display the direction of a directional light using an arrow model. The directional light's direction is a unit vector but models are rotated using quaternions. So.. How do I rotate this model to match the direction of the light? Or am I crazy and I can't really do that, given that