quaternions

Why won't my Quaternion rotate properly?

左心房为你撑大大i 提交于 2019-12-06 07:10:48
问题 Ok, we are not talking about OpenGL with this question, but this will be used with OpenGL ES 2.0. Question: How do create and rotate a Quaternion with the following code? I have been reading up and studying about this and still can't quite gasp the concepts. I thought I understood it, but once I started making some calculations to rotate the quaternion I realized I can't even get back to where I started. So let us say that we have a cube, and the center of it is at (0, 0, 0). We want to

Flipping issue when interpolating Rotations using Quaternions

☆樱花仙子☆ 提交于 2019-12-06 06:49:26
I use slerp to interpolate between two quaternions representing rotations. The resulting rotation is then extracted as Euler angles to be fed into a graphics lib. This kind of works, but I have the following problem; when rotating around two (one works just fine) axes in the direction of the green arrow as shown in the left frame here the rotation soon jumps around to rotate from the opposite site to the opposite visual direction, as indicated by the red arrow in the right frame. This may be logical from a mathematical perspective (although not to me), but it is undesired. How could I achieve

Convert Unity transforms to THREE.js rotations

邮差的信 提交于 2019-12-06 05:51:35
问题 How can I match the rotation of a THREE.js camera or object to a transform from a Unity GameObject? Unity uses a left-handed system with a ZXY euler order. THREE.js uses a right-handed system with an XYZ euler order. What transformations need to be made to convert GameObject.transform.rotation (Quaternion) to Object3D.rotation (THREE.Vector3)? 回答1: We ended up fixing this as follows: Assuming you get qx , qy , qz and qw from Unity's quaternion, we apply the conversion below in JavaScript /

Compare device 3D orientation with the sun position

ε祈祈猫儿з 提交于 2019-12-06 04:04:11
问题 I am working on an app that requires the user to aim his iPhone to the sun in order to trigger a special event. I can retrieve the device 3D orientation quaternion based on the gyroscope and CoreMotion framework, from this I can get the yaw, roll and pitch angles. I can also compute the sun's azimuth and zenith angle based on the current date and time (GMT) and the latitude and longitude. What I am trying to figure out next is how to compare these two sets of values (phone orientation and sun

Gyroscope with compass help needed

女生的网名这么多〃 提交于 2019-12-06 02:21:14
I need to have a game object point north AND I want to combine this with gyro.attitude input. I have tried, unsuccessfully, to do this in one step. That is, I couldn't make any gyro script, which I found on the net, work with the additional requirement of always pointing north. Trust me, I have tried every script I could find on the subject. I deduced that it's impossible and probably was stupid to think it could be done; at least not this way (i.e. all-in-one). I guess you could say I surmised that you can't do two things at once. Then I thought possibly I could get the same effect by

Why is my straightforward quaternion multiplication faster than SSE?

廉价感情. 提交于 2019-12-06 01:24:43
问题 I've been going through a few different quaternion multiplication implementations, but I've been rather surprised to see that the reference implementation is, so far, my fastest. This is the implementation in question: inline static quat multiply(const quat& lhs, const quat& rhs) { return quat((lhs.w * rhs.x) + (lhs.x * rhs.w) + (lhs.y * rhs.z) - (lhs.z * rhs.y), (lhs.w * rhs.y) + (lhs.y * rhs.w) + (lhs.z * rhs.x) - (lhs.x * rhs.z), (lhs.w * rhs.z) + (lhs.z * rhs.w) + (lhs.x * rhs.y) - (lhs.y

Smooth rotation with quaternions

亡梦爱人 提交于 2019-12-05 10:53:49
Quaternion can describe not only rotation, but also an orientation, i.e. rotation from initial (zero) position. I was wishing to model smooth rotation from one orientation to another. I calculated start orientation startOrientation and end orientation endOrientation and was wishing to describe intermediate orientations as startOrientation*(1-argument) + endOrientation*argument while argument changes from 0 to 1 . The code for monkey engine update function is follows: @Override public void simpleUpdate(float tpf) { if( endOrientation != null ) { if( !started ) { started = true; } else {

How to convert the positions of connected joints to relative delta rotations

我是研究僧i 提交于 2019-12-05 10:50:06
I'm currently implementing a C++ solution to track motion of multiple objects. In that I have tracked points of those objects in a frame sequences such that multiple points in each frame. As a result of that I have x, y, z coordinates of those points of the entire frame sequence. By studying an already generated model I understood it consists of a joints system which move relative to each other. Every joint has a parent and their movements are written relative to its parent in Quaternion format. Therefore, I want to convert my x,y,z coordinates, which are in 3D space relative to same origin,

Longitude / Latitude to quaternion

北慕城南 提交于 2019-12-05 09:23:33
I've got a longitude and latitude and want to convert this to a quaternion and wondering how I can do this? I want to use this, because I've got an app which projects the earth on a sphere and I want to rotate from one location to another one. Best! There's a way to go about this without using matrices or vectors, similar to this numpy implementation . We can think of longitude/latitude as two quaternion rotations composed together. Let's work with a Z-up right-handed coordinate system. Let's call longitude φ and latitude θ, and the point represented by the two as (φ, θ). For visualization,

Convert a Unit Vector to a Quaternion

核能气质少年 提交于 2019-12-05 06:22:39
So I'm very new to quaternions, but I understand the basics of how to manipulate stuff with them. What I'm currently trying to do is compare a known quaternion to two absolute points in space. I'm hoping what I can do is simply convert the points into a second quaternion, giving me an easy way to compare the two. What I've done so far is to turn the two points into a unit vector. From there I was hoping I could directly plug in the i j k into the imaginary portion of the quaternion with a scalar of zero. From there I could multiply one quaternion by the other's conjugate, resulting in a third