quaternions

Applying quaternion rotation to a vector time series

偶尔善良 提交于 2021-01-04 05:55:06
问题 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 (

Eigen: convert Matrix3d rotation to Quaternion

本小妞迷上赌 提交于 2020-07-03 05:49:20
问题 I'm trying to convert a Matrix3d rotation to a Quaternion<double> , but I got only weird compiler errors so far. The code I'm using is: Quaternion<double> getQuaternionFromRotationMatrix(const Matrix3d& mat) { AngleAxisd aa; aa = mat; Quaternion<double> q = aa;// conversion error return q; } And the compiler errors: path/src/Utils.cpp: In function ‘Eigen::Quaternion<double> Utils::getQuaternionFromRotationMatrix(const Matrix3d&)’: path/src/Utils.cpp:55:26: error: conversion from ‘Eigen:

Eigen: convert Matrix3d rotation to Quaternion

混江龙づ霸主 提交于 2020-07-03 05:46:25
问题 I'm trying to convert a Matrix3d rotation to a Quaternion<double> , but I got only weird compiler errors so far. The code I'm using is: Quaternion<double> getQuaternionFromRotationMatrix(const Matrix3d& mat) { AngleAxisd aa; aa = mat; Quaternion<double> q = aa;// conversion error return q; } And the compiler errors: path/src/Utils.cpp: In function ‘Eigen::Quaternion<double> Utils::getQuaternionFromRotationMatrix(const Matrix3d&)’: path/src/Utils.cpp:55:26: error: conversion from ‘Eigen:

Rotating a gun while flipping it in Unity

删除回忆录丶 提交于 2020-06-29 03:45:28
问题 I have a c# script that can rotate a gun to point at the cursor. I needed the gun to flip to the other side of the player when the cursor is above or below the player. I solved this problem with the following script: (inside the update function) Vector2 weaponDistance = Camera.main.ScreenToWorldPoint(Input.mousePosition) - weapon.transform.position; float weaponRotation = Mathf.Atan2 (weaponDistance.y, weaponDistance.x) * Mathf.Rad2Deg; if (weaponRotation < 90f && weaponRotation > -90f) {

Converting glm::lookat matrix to quaternion and back

半城伤御伤魂 提交于 2020-04-10 08:03:27
问题 I am using glm to create a camera class, and I am running into some problems with a lookat function. I am using a quaternion to represent rotation, but I want to use glm's prewritten lookat function to avoid duplicating code. This is my lookat function right now: void Camera::LookAt(float x, float y, float z) { glm::mat4 lookMat = glm::lookAt(position, glm::vec3(x, y, z), glm::vec3(0, 1, 0)); rotation = glm::toQuat(lookMat); } However when I call LookAt(0.0f,0.0f,0.0f) , my camera is not

Gravity Compensation in IMU Data

自闭症网瘾萝莉.ら 提交于 2020-03-26 04:03:50
问题 I'm trying to do gravity compensation on my accelerometer data. Given an Accelerometer, with 6 DOF (Accelerometer, Gyroscope) I want to remove/compensate the effect of the gravity in accelerometer reading (Accelerometer can rotate freely). Following is the way I store raw sensor values to a struct called sample : uint8_t *p=data; // p is a pointer to the sensor data int i; for(i=0; i<4; i++) // quaternion { sample.quaternion[i]=((float)get_int32(p))/(1<<29); len+=snprintf(s+len, sizeof(line)

How to install IMUsim

馋奶兔 提交于 2020-03-18 05:17:20
问题 This a guide rather than a question, because I spent a LOT of time fighting with compilation errors when installing IMUsim, and I know that many other researchers have struggled. The IMUsim code is currently unmaintained and the installation documentation is lacking. If you simply clone the current IMUsim repo and follow the instructions to build from source, it will fail citing missing files. See my answer below for the solution. 回答1: Installation instructions First, download the repo: git

How to use a pan gesture to rotate a camera in SceneKit using quaternions

和自甴很熟 提交于 2020-01-23 11:04:10
问题 I'm building a 360 video viewer using the iOS SceneKit framework. I'd like to use a UIPanGestureRecognizer to control the camera's orientation. SCNNodes have several properties we can use to specify their rotation: rotation (a rotation matrix), orientation (a quaternion), eulerAngles (per axis angles). Everything I've read says to avoid using euler angles in order to avoid gimbal lock. I'd like to use quaternions for a few reasons which I won't go into here. I'm having trouble getting this to