quaternions

Glm Quaternion lookat function

别来无恙 提交于 2021-02-18 03:38:05
问题 I am trying to write a lookat function that uses glm::quat to represent rotations, based of off this answer. I am running into trouble getting a correct angle however. This is my lookat function: void Camera::LookAt(float x, float y, float z) { glm::vec3 lookVector = glm::vec3(x, y, z); assert(lookVector != position); glm::vec3 direction = glm::normalize(lookVector-position); float dot = glm::dot(glm::vec3(0, 0, -1), direction); if (fabs(dot - (-1.0f)) < 0.000001f) rotation = glm::quat

Eigen: matrix to quaternion and back have different result

三世轮回 提交于 2021-02-08 04:10:52
问题 I use Eigen library to covert matrix to quaternion, but when I turn one of the matrix to quaternion and burn it back, it turn out to be another matrix which is identity matrix. The rotation matrix I use was decomposed from a transform matrix. Eigen::Matrix3f R3d = R.topLeftCorner<3,3>(); *Rquat = R3d; R3d = (*Rquat).normalized().toRotationMatrix(); What may cause this problem? This is the matrix before change to quaternion and This is the matrix when I turn it back form the quaternion 回答1:

Eigen: matrix to quaternion and back have different result

旧巷老猫 提交于 2021-02-08 04:10:34
问题 I use Eigen library to covert matrix to quaternion, but when I turn one of the matrix to quaternion and burn it back, it turn out to be another matrix which is identity matrix. The rotation matrix I use was decomposed from a transform matrix. Eigen::Matrix3f R3d = R.topLeftCorner<3,3>(); *Rquat = R3d; R3d = (*Rquat).normalized().toRotationMatrix(); What may cause this problem? This is the matrix before change to quaternion and This is the matrix when I turn it back form the quaternion 回答1:

Moving cannonJS object in 3D according to its quaternion

微笑、不失礼 提交于 2021-02-08 03:51:23
问题 I would like to achieve a space ship like move on a cannonJS body. (Im really a beginner) I found some examples but none of them are exactly what I'm looking for. As i know the correct way to move an object, is to change its velocity. Here's what I have done here: http://codepen.io/Tomo0613/pen/xVjqqK enter code here But i definitely have problems with understanding quaternions. Is there a way to update, the vector of the body according to its quaternion as i rotate it, or that's always

Moving cannonJS object in 3D according to its quaternion

岁酱吖の 提交于 2021-02-08 03:50:44
问题 I would like to achieve a space ship like move on a cannonJS body. (Im really a beginner) I found some examples but none of them are exactly what I'm looking for. As i know the correct way to move an object, is to change its velocity. Here's what I have done here: http://codepen.io/Tomo0613/pen/xVjqqK enter code here But i definitely have problems with understanding quaternions. Is there a way to update, the vector of the body according to its quaternion as i rotate it, or that's always

Moving cannonJS object in 3D according to its quaternion

做~自己de王妃 提交于 2021-02-08 03:49:23
问题 I would like to achieve a space ship like move on a cannonJS body. (Im really a beginner) I found some examples but none of them are exactly what I'm looking for. As i know the correct way to move an object, is to change its velocity. Here's what I have done here: http://codepen.io/Tomo0613/pen/xVjqqK enter code here But i definitely have problems with understanding quaternions. Is there a way to update, the vector of the body according to its quaternion as i rotate it, or that's always

3D Rotation using System.Numerics.Quaternion

一个人想着一个人 提交于 2021-01-29 15:40:18
问题 Anybody here know how to rotate a vector3 using .net(4.6 and up) System.Numerics.Quaternion? My maths is pretty poor though and my understanding only really goes as far as: quaternions are 4d "structures" that can produce translation, scaling and rotation in 3d. So I had a play and cannot get any rotation. Doing what seemed obvious : changing the W component of the Quaternion.(angle) then reading the vector produces scaling ?!? Anyone able to help or point me in the right direction for help?

Proper conversion between Quaternions and Spherical Rotation Coordinates?

五迷三道 提交于 2021-01-28 07:52:34
问题 I'm learning about more quaternion conversions and I have a question regarding quaternion to spherical rotation conversion code at the following section of this website: http://web.archive.org/web/20041029003853/http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q59 What are angle and sin_angle in this code supposed to be? Angle is never used so I was guessing it's the rotation angle. Is sin_angle supposed to be sin_a? If this was a function returning an array of float with the spherical

Eigen: convert rotation matrix to quaternion then back getting completely different matrices

雨燕双飞 提交于 2021-01-28 07:27:26
问题 Can anyone help me out with Eigen? I tried to convert quaternion to matrix and then back and got completely different matrices. I am not able to trust quaternion before understanding this issue. Here is the code: #include <Eigen/Geometry> #include <iostream> void Print_Quaternion(Eigen::Quaterniond &q){ std::cout<<"["<<q.w()<<" "<<q.x()<<" "<<q.y()<<" "<<q.z()<<"]"<<std::endl; } void Verify_Orthogonal_Matrix(Eigen::Matrix3d &m) { std::cout<<"|c0|="<<m.col(0).norm()<<",|c1|="<<m.col(1).norm()<

Applying quaternion rotation to a vector time series

做~自己de王妃 提交于 2021-01-04 05:57:40
问题 I have a time series of 3D vectors in a Python numpy array similar to the following: array([[-0.062, -0.024, 1. ], [-0.071, -0.03 , 0.98 ], [-0.08 , -0.035, 0.991], [-0.083, -0.035, 0.98 ], [-0.083, -0.035, 0.977], [-0.082, -0.035, 0.993], [-0.08 , -0.034, 1.006], [-0.081, -0.032, 1.008], ....... I want to rotate each vector around a specified axis through a specified angle theta . I have been using quaternions to achieve this for one vector as found here in henneray's answer. v1 = np.array (