quaternions

LWJGL - Problems implementing 'roll' in a 6DOF Camera using quaternions and a translation matrix

狂风中的少年 提交于 2020-01-22 20:37:49
问题 I've spent a couple weeks on this issue and can't seem to find a proper solution and need some advice. I'm working on creating a Camera class using LWJGL/Java, and am using Quaternions to handle bearing (yaw), pitch and roll rotations. I'd like this camera to handle all 6 degrees of movement in 3D space, and roll. Bearing, Pitch and Roll are all quaternions. I multiply them into a 'change' quaternion, and create a translation matrix from that. I put that in a float buffer, and multiply the

Quaternion from two vector pairs

时间秒杀一切 提交于 2020-01-14 03:51:12
问题 I have two vector pairs (before and after rotation). before rotation: [x1,y1,z1] [x2,y2,z2] after rotation: [x1',y1',z1'] [x2',y2',z2'] How to create a quaternion representing this rotation? 回答1: In most cases there is no rotation which transforms 2 vectors into 2 other vectors. Here is a simple way to visualize why: a rotation does not change the angle between vectors. If the angle between the 2 vectors before the rotation is different from the angle between the 2 vectors after the rotation,

Can someone explain how I can use Quanternions to use the mouse to look around like a FPS?

喜你入骨 提交于 2020-01-12 10:21:29
问题 Yesterday I asked: How could simply calling Pitch and Yaw cause the camera to roll? Basically, I found out because of "Gimbal Lock" that if you pitch + yaw you will inevitably produce a rolling effect. For more information you can read that question. I'm trying to stop this from happening. When you look around in a normal FPS shooter you don't have your camera rolling all over the place! Here is my current passive mouse func: int windowWidth = 640; int windowHeight = 480; int oldMouseX = -1;

Quaternion is flipping sign for very similar rotations?

南楼画角 提交于 2020-01-12 10:16:34
问题 Consider the following minimal working example: #include <iostream> #include <math.h> #include <eigen3/Eigen/Dense> int main() { // Set the rotation matrices that give an example of the problem Eigen::Matrix3d rotation_matrix_1, rotation_matrix_2; rotation_matrix_1 << 0.15240781108708346, -0.98618841818279246, -0.064840288106743013, -0.98826031445019891, -0.1527775600229907, 0.00075368177315370682, -0.0106494132438156, 0.063964216524108775, -0.99789536976680049; rotation_matrix_2 << -0

Quaternion is flipping sign for very similar rotations?

隐身守侯 提交于 2020-01-12 10:14:06
问题 Consider the following minimal working example: #include <iostream> #include <math.h> #include <eigen3/Eigen/Dense> int main() { // Set the rotation matrices that give an example of the problem Eigen::Matrix3d rotation_matrix_1, rotation_matrix_2; rotation_matrix_1 << 0.15240781108708346, -0.98618841818279246, -0.064840288106743013, -0.98826031445019891, -0.1527775600229907, 0.00075368177315370682, -0.0106494132438156, 0.063964216524108775, -0.99789536976680049; rotation_matrix_2 << -0

How to interpolate rotations?

浪尽此生 提交于 2020-01-12 07:29:07
问题 I have two vectors describing rotations; a start rotation A and a target rotation B. How would I best go about interpolating A by a factor F to approach B? Using a simple lerp on the vectors fails to work when more than one dimension needs to be interpolated (i.e. produces undesirable rotations). Maybe building quaternions from the rotation vectors and using slerp is the way to go. But how, then, could I extract a vector describing the new rotation from the resulting quaternion? Thanks in

“Distance” (or angular magnitude) between two quaternions?

谁说我不能喝 提交于 2020-01-12 05:45:06
问题 I want to find the "distance" between two quaternions. By "distance" I mean a single float or int, not another quaternion (that would be the difference, i.e. inverse(q1)*q2 ). I guess you could call what I want "angular magnitude". I need to apply more torque to a physics object the further it's rotated from its original angle. I don't understand the maths involved in quaternions, so a code-based example would be most helpful. I've looked at several other questions but I don't believe any

Arcball Rotation with Quaternions (using iOS GLKit)

一笑奈何 提交于 2020-01-11 19:57:06
问题 I'm looking for a simple implementation for arcball rotation on 3D models with quaternions, specifically using GLKit on iOS . So far, I have examined the following sources: Arcball rotation with GLKit How to rotate a 3D object with touches using OpenGL I've also been trying to understand source code and maths from here and here. I can rotate my object but it keeps jumping around at certain angles, so I fear gimbal lock is at play. I'm using gesture recognizers to control the rotations (pan

Switch chirality of a quaternion in code?

限于喜欢 提交于 2020-01-07 06:44:32
问题 I have quaternion data that I am trying to switch from a right-handed Y-up coordinate space, to a left-handed Z-up coordinate space. From reading up on this, what I need to do is switch the chirality . The only info i can find is this And i cannot wrap my head around it. Say that I have my Quaternion as: public static float[] quat= new float[4](0.70711,0.70711,0,0); In c# code, how do i switch the chirality? I have tried negating the axis, and simply swapping the Z and Y values. I have tried

Difficulty with rotating child around parent axes

坚强是说给别人听的谎言 提交于 2020-01-06 15:11:26
问题 I know there's a million questions on rotating, I've tried and read many things but I can't seem to solve this particular problem. The only way I can think to explain it properly is with some poorly drawn diagrams so here goes! I have a parent object, and a child object (here it's represented as a die where opposite faces add up to 7), the axes in this diagram are the parents X, Y, and Z directions Starting point: I want the child object to have two methods that I'll call RotateZ and RotateX