quaternions

Get quaternion from Android gyroscope?

时光总嘲笑我的痴心妄想 提交于 2019-11-28 22:07:06
The official development documentation suggests the following way of obtaining the quaternion from the 3D rotation rate vector (wx, wy, wz) . // Create a constant to convert nanoseconds to seconds. private static final float NS2S = 1.0f / 1000000000.0f; private final float[] deltaRotationVector = new float[4](); private float timestamp; public void onSensorChanged(SensorEvent event) { // This timestep's delta rotation to be multiplied by the current rotation // after computing it from the gyro sample data. if (timestamp != 0) { final float dT = (event.timestamp - timestamp) * NS2S; // Axis of

'Difference' between two quaternions

穿精又带淫゛_ 提交于 2019-11-28 21:18:04
I'm working in Ogre, but it's a general quaternion problem. I have an object, to which I apply a rotation quaternion Q1 initially. Later, I want to make it as if I initially rotated the object by a different quaternion Q2. How do I calculate the quaternion which will take the object, already rotated by Q1, and align it as if all I did was apply Q2 to the initial/default orientation? I was looking at (s)lerping, but I am not sure if this only valid on orientations rather than rotations ? It sounds like you want the inverse of Q1 times Q2. Transforming by the inverse of Q1 will rotate the object

Gravity Compensation in Accelerometer Data

纵然是瞬间 提交于 2019-11-28 20:57:31
Given an Accelerometer with 9 DOF (Accelerometer, Gyroscope and Magnetometer) I want to remove/compensate the effect of the gravity in accelerometer reading (Accelerometer can rotate freely). The sensor gives the orientation in quaternion representation relative to a (magnetic)north, west and up reference frame. I found this http://www.varesano.net/blog/fabio/simple-gravity-compensation-9-dom-imus but couldn't understand the basis for the given equation. How could I achieve this given above information? You need to rotate the accelerometer reading by the quaternion into the Earth frame of

Three.js Object3d cylinder rotation to align to a vector

前提是你 提交于 2019-11-28 20:49:10
I have searched far and wide, but can't seem to figure this pretty basic thing out. I have seen other examples on stackoverflow and elsewhere from a year or two ago, but they fail to work with the latest version of Three.js. Here is a version of what i'm working on: http://medschoolgunners.com/sandbox/3d/ . I'm trying to get the grey cone to exactly align with the unlabeled red vector. Ie. I want the tip of the cone to be exactly aligned with the vector and point out from the origin in that direction. Here is the code I have right now: //FUNCTION TO CREATE A CYLINDER function create_cylinder

Euler angle to Quaternion then Quaternion to euler angle

好久不见. 提交于 2019-11-28 20:44:42
I'm using lib glm ( http://glm.g-truc.net/ ) for test quaternion but I've a problem; when I convert euler angle to quaternion then immediatly quaternion to euler angles, my result are totally different from my initial euler angles. Is this normal? Could it be because the rotations are not communative? Code test: #include <glm\quaternion.hpp> #include <math.h> #define PI M_PI #define RADTODEG(x) ( (x) * 180.0 / PI ) #define DEGTORAD(x) ( (x) * PI / 180.0 ) int main( void ) { float RotX = 90.f; float RotY = 180.f; float RotZ = -270.f; if ( RotX || RotY || RotZ ) { std::cout << "Init: x= " <<

Quaternion and normalization

*爱你&永不变心* 提交于 2019-11-28 17:13:30
问题 I know that quaternions need to be normalized if I want to rotate a vector. But are there any reasons to not automatically normalize a quaternion? And if there are, what quaternion operations do result in non-normalized quaternions? Multiplying two quaternions? Dot product? Sorry, if this question is a little bit fuzzy. I'm still trying wrap my head around quaternions. 回答1: Any operation that produces a quaternion will need to be normalized because floating-point precession errors will cause

“Average” of multiple quaternions?

情到浓时终转凉″ 提交于 2019-11-28 16:30:42
I'm trying to make the switch from matrices to quaternions for skeletal animation in my OpenGL program, but I've encountered a problem: Given a number of unit quaternions, I need to get a quaternion that when used to transform a vector will give a vector that is the average of the vector transformed by each quaternion individually. (with matrices I would simply add the matrices together and divide by the number of matrices) Contrary to popular belief in the computer graphics industry, there is a straightforward algorithm to solve this problem which is robust, accurate, and simple that comes

Why are quaternions used for rotations?

孤街浪徒 提交于 2019-11-28 15:10:35
I'm a physicist, and have been learning some programming, and have come across a lot of people using quaternions for rotations instead of writing things in matrix/vector form. In physics, there are very good reasons we don't use quaternions (despite the bizarre story that's occasionally told about Hamilton/Gibbs/etc). Physics requires that our descriptions have good analytic behavior (this has a precisely defined meaning, but in some rather technical ways that go far beyond what's taught in normal intro classes, so I won't go into any detail). It turns out that quaternions don't have this nice

Rotate a 3D object on 3 axis in JavaFX properly

风流意气都作罢 提交于 2019-11-28 08:47:27
So the method that I've used so far to rotate objects in JavaFX was that I layered it in 3 groups, each of them with a Rotate attached and locked to a single axis like so: Rotate heading, roll, pitch; Group normalrotate, rollrotate, verticalrotate; heading.setAxis(new Point3D(0,1,0)); normalrotate.getTransforms().add(heading); roll.setAxis(new Point3D(0,0,1)); rollrotate.getTransforms().add(roll); pitch.setAxis(new Point3D(1,0,0)); verticalrotate.getTransforms().add(pitch); and did a setAngle() for each time I needed to rotate the object. This worked very well for only heading and roll until i

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

人走茶凉 提交于 2019-11-27 20:18:22
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 parameter)on screen which guide to the correct orientation the picture was taken. On reaching the