quaternions

Difference between the two quaternions

微笑、不失礼 提交于 2019-11-30 03:42:54
Solved I'm making a 3D portal system in my engine (like Portal game). Each of the portals has its own orientation saved in a quaternion. To render the virtual scene in one of the portals I need to calculate the difference between the two quaternions, and the result use to rotate the virtual scene. When creating the first portal on the left wall, and second one on the right wall, the rotation from one to another will take place in only one axis, but for example when the first portal will be created on the floor, and the second one on the right wall, the rotation from one to another could be in

Is there an algorithm for converting quaternion rotations to Euler angle rotations?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 19:47:25
Is there an existing algorithm for converting a quaternion representation of a rotation to an Euler angle representation? The rotation order for the Euler representation is known and can be any of the six permutations (i.e. xyz, xzy, yxz, yzx, zxy, zyx). I've seen algorithms for a fixed rotation order (usually the NASA heading, bank, roll convention) but not for arbitrary rotation order. Furthermore, because there are multiple Euler angle representations of a single orientation, this result is going to be ambiguous. This is acceptable (because the orientation is still valid , it just may not

How to find correct rotation from one vector to another?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 15:23:20
问题 I have two objects, and each object has two vectors: normal vector up vector Like on this image: Up vector is perpendicular to normal vector. Now I want to find unique rotation from one object to another, how to do that? I have one method to find rotation between one vector to another, and it works. The problem is that I need to take care the two vectors: normal vector and up vector. If I use this method to rotate normal vector from object one to normal from object two, the up vector could be

How to derive “standard” rotations from three.js when using quaternions?

我是研究僧i 提交于 2019-11-29 14:01:30
问题 Newbie stackoverflow participant, newbie 3D programmer, and far from a math wiz... so I'll try to frame this question as clearly as I can, hoping it makes sense, and hoping for an answer that's not a mile over my head. I've written a very cool app using three.js that lets the user fly through 3D space and explore a solar system. The flight model is loosely based on the Fly.Controller example/extension in the three.js package which taught me to use quaternions for keeping all the axis

How to properly rotate a quaternion along all axis?

流过昼夜 提交于 2019-11-29 09:48:04
问题 I want to code a first person camera with its rotation stored in a quaternion. Unfortunately there is something wrong with the rotation. The following function is responsible to rotate the camera. The parameters Mouse and Speed pass the mouse movement and rotation speed. Then the function fetches the rotation quaternion, rotates it and stores the result. By the way, I'm using Bullet Physics that is where the types and functions come from. void Rotate(vec2 Mouse, float Speed) { btTransform

How do I rotate a Quaternion with 2nd Quaternion on its local or world axes without using transform.Rotate?

我与影子孤独终老i 提交于 2019-11-29 08:52:33
Transform.Rotate has a very helpful interface for selecting whether or not a rotation should be made relative to world axes or the local axes. Behind the scenes, it's doing some math to the transform's rotation , a Quaternion , with another Quaternion . And the exact nature of this math changes depending on if you choose the local or world flag. How can I do this sort of math without assigning the first Quaternion to a Transform's rotation (wasting memory and/or time) just to do some math with it? Suppose my first Quaternion is Quaternion q1 = Quaternion.Euler(0f,0f,90f); and the second is

How to get the euler-angles from the rotation vector (Sensor.TYPE_ROTATION_VECTOR)

倾然丶 夕夏残阳落幕 提交于 2019-11-29 07:21:40
I rotated my android device in x direction (from -180 degree to 180 degree), see image below. And I assume only Rotation vector x value is changed. Y and z maybe have some noise, but it should be not much difference among the values. However, I receive this. Kindly see https://docs.google.com/spreadsheets/d/1ZLoSKI8XNjI1v4exaXxsuMtzP0qWTP5Uu4C3YTwnsKo/edit?usp=sharing I suspect my sensor has some problem. Any idea? Thank you very much. Jimmy Your sensor is fine. Well, the rotation vector entries cannot simply be related to the rotation angle around a particular axis. The SensorEvent structure

Quaternion - Rotate To

牧云@^-^@ 提交于 2019-11-29 05:06:02
I have some object in world space, let's say at (0,0,0) and want to rotate it to face (10,10,10). How do i do this using quaternions? This question doesn't quite make sense. You said that you want an object to "face" a specific point, but that doesn't give enough information. First, what does it mean to face that direction? In OpenGL, it means that the -z axis in the local reference frame is aligned with the specified direction in some external reference frame. In order to make this alignment happen, we need to know what direction the relevant axis of the object is currently "facing". However,

How to multiply two quaternions with minimal instructions?

核能气质少年 提交于 2019-11-29 03:05:41
问题 After some thought, I came up with the following code for multiplying two quaternions using SSE: #include <pmmintrin.h> /* SSE3 intrinsics */ /* multiplication of two quaternions (x, y, z, w) x (a, b, c, d) */ __m128 _mm_cross4_ps(__m128 xyzw, __m128 abcd) { /* The product of two quaternions is: */ /* (X,Y,Z,W) = (xd+yc-zb+wa, -xc+yd+za+wb, xb-ya+zd+wc, -xa-yb-zc+wd) */ __m128 wzyx = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(0,1,2,3)); __m128 baba = _mm_shuffle_ps(abcd, abcd, _MM_SHUFFLE(0,1,0,1

From quaternions to OpenGL rotations

只愿长相守 提交于 2019-11-28 23:39:15
I have an object which I want to rotate via keys. The object should yaw, pitch and roll. After trying a lot, I figured out that glRotate has its limitations and it won't be possible to implement something like that with that function. I've researched a bit and found out about quaternion-based rotation. It would be also possible to rotate via a rotation matrix, but almost everyone describes the quaternions as the best ever. I have read about the quaternions and understood them fairly well, but how to implement them in my OpenGL program is still a mystery. Does anyone know a small example? Not