quaternions

Orient object's rotation to a spline point tangent in THREE.JS

ぃ、小莉子 提交于 2019-11-27 19:56:05
I am using SplineCurve3 to plot a line only on the X and Y axis, I have a cube successfully animating along this line by using spline.getPoint(t) where t is 0-1 in time. I am trying to orient the cube to the line via its up vector which is Y using the dot product. It is almost aligned but ever so slightly out. I thought that I would use the dot product of the Y vector and the tangent of the current point as the angle to rotate a quaternion to. Here is my render function: function render() { var updateMatrix = new THREE.Matrix4(); updateMatrix.setPosition(spline.getPoint(t)); var angle = new

From quaternions to OpenGL rotations

牧云@^-^@ 提交于 2019-11-27 14:58:45
问题 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

Get quaternion from Android gyroscope?

做~自己de王妃 提交于 2019-11-27 14:13:15
问题 The official development documentation suggests the following way of obtaining the quaternion from the 3D rotation rate vector (wx, wy, wz) . // Create a constant to convert nanoseconds to seconds. private static final float NS2S = 1.0f / 1000000000.0f; private final float[] deltaRotationVector = new float[4](); private float timestamp; public void onSensorChanged(SensorEvent event) { // This timestep's delta rotation to be multiplied by the current rotation // after computing it from the

Gravity Compensation in Accelerometer Data

拟墨画扇 提交于 2019-11-27 13:21:16
问题 Given an Accelerometer with 9 DOF (Accelerometer, Gyroscope and Magnetometer) I want to remove/compensate the effect of the gravity in accelerometer reading (Accelerometer can rotate freely). The sensor gives the orientation in quaternion representation relative to a (magnetic)north, west and up reference frame. I found this http://www.varesano.net/blog/fabio/simple-gravity-compensation-9-dom-imus but couldn't understand the basis for the given equation. How could I achieve this given above

Euler angle to Quaternion then Quaternion to euler angle

强颜欢笑 提交于 2019-11-27 13:07:46
问题 I'm using lib glm (http://glm.g-truc.net/) for test quaternion but I've a problem; when I convert euler angle to quaternion then immediatly quaternion to euler angles, my result are totally different from my initial euler angles. Is this normal? Could it be because the rotations are not communative? Code test: #include <glm\quaternion.hpp> #include <math.h> #define PI M_PI #define RADTODEG(x) ( (x) * 180.0 / PI ) #define DEGTORAD(x) ( (x) * PI / 180.0 ) int main( void ) { float RotX = 90.f;

SceneKit – Mapping physical 360 rotation

亡梦爱人 提交于 2019-11-27 11:17:40
问题 I am having a hard time mapping device motion (sensor fusion) to SceneKit node rotation. The premise of the problem is as follows, I have sphere, and the camera is positioned to be inside the the sphere such that the geometric center of sphere and camera node's center coincide. What i want to achieve is when i rotate physically around a point, the motion needs to be mapped accurately on the camera as well. The implementaion details are as follows: I have a node, with a sphere as geomertry and

“Average” of multiple quaternions?

心不动则不痛 提交于 2019-11-27 09:40:26
问题 I'm trying to make the switch from matrices to quaternions for skeletal animation in my OpenGL program, but I've encountered a problem: Given a number of unit quaternions, I need to get a quaternion that when used to transform a vector will give a vector that is the average of the vector transformed by each quaternion individually. (with matrices I would simply add the matrices together and divide by the number of matrices) 回答1: Contrary to popular belief in the computer graphics industry,

Convert Quaternion rotation to rotation matrix?

若如初见. 提交于 2019-11-27 07:39:56
Basically, given a quaterion (qx, qy, qz, qw)... How can i convert that to an OpenGL rotation matrix? I'm also interested in which matrix row is "Up", "Right", "Forward" etc... I have a camera rotation in quaternion that I need in vectors... The following code is based on a quaternion (qw, qx, qy, qz), where the order is based on the Boost quaternions: boost::math::quaternion<float> quaternion; float qw = quaternion.R_component_1(); float qx = quaternion.R_component_2(); float qy = quaternion.R_component_3(); float qz = quaternion.R_component_4(); First you have to normalize the quaternion:

Rotate a 3D object on 3 axis in JavaFX properly

限于喜欢 提交于 2019-11-27 02:25:21
问题 So the method that I've used so far to rotate objects in JavaFX was that I layered it in 3 groups, each of them with a Rotate attached and locked to a single axis like so: Rotate heading, roll, pitch; Group normalrotate, rollrotate, verticalrotate; heading.setAxis(new Point3D(0,1,0)); normalrotate.getTransforms().add(heading); roll.setAxis(new Point3D(0,0,1)); rollrotate.getTransforms().add(roll); pitch.setAxis(new Point3D(1,0,0)); verticalrotate.getTransforms().add(pitch); and did a setAngle

Orient object's rotation to a spline point tangent in THREE.JS

吃可爱长大的小学妹 提交于 2019-11-26 20:03:34
问题 I am using SplineCurve3 to plot a line only on the X and Y axis, I have a cube successfully animating along this line by using spline.getPoint(t) where t is 0-1 in time. I am trying to orient the cube to the line via its up vector which is Y using the dot product. It is almost aligned but ever so slightly out. I thought that I would use the dot product of the Y vector and the tangent of the current point as the angle to rotate a quaternion to. Here is my render function: function render() {