quaternions

Quaternion to EulerXYZ, how to differentiate the negative and positive quaternion

人走茶凉 提交于 2019-12-11 13:45:10
问题 I've been trying to figure out the difference between these, and why ToEulerXYZ does not get the right rotation. Using MathGeoLib: axisX: x 0.80878228 float y -0.58810818 float z 0.00000000 float axisY: x 0.58811820 float y 0.80877501 float z 0.00000000 float axisZ: x 0.00000000 float y 0.00000000 float z 1.0000000 float Code: Quat aQ = Quat::RotateAxisAngle(axisX, DegToRad(30)) * Quat::RotateAxisAngle(axisY, DegToRad(60)) * Quat::RotateAxisAngle(axisZ, DegToRad(40)); float3 eulerAnglesA = aQ

Quaternions, rotate a model and align with a direction

一个人想着一个人 提交于 2019-12-11 13:02:33
问题 Suppose you have quaternion that describes the rotation of a 3D Model. What I want to do is, given an Object (with rotationQuaternion, side vector...), I want to align it to a target point. For a spaceship, I want the cockpit to point to a target. Here is some code I have ... It's not doing what I want and I don't know why... if (_target._ray.Position != _obj._ray.Position) { Vector3 vec = Vector3.Normalize(_target._ray.Position - _obj._ray.Position); float angle = (float)Math.Acos(Vector3

Obtaining momentum quaternion from two quaternions and timestep

若如初见. 提交于 2019-12-11 09:53:01
问题 I have a quaternion which holds the rotation of an object. During the frame I modify it and obtain a new quaternion. I can calculate a quaternion that rotates from 'previous frame' to 'current frame'. I cannot figure out, however, how to 'divide by t' this quaternion to get the rotation-per-second that I need. I.e, based on the timestep, I need to know what the quaternion would look like had it been applied to itself an X amount of times (meaning, 28.5 times at 28.5 fps, etcetera). Would

device position from rotation vector with quaternions

本小妞迷上赌 提交于 2019-12-11 09:34:45
问题 I am at a loss. I am trying to evaluate the rotation vector sensor to figure out which way my device is facing. Basically, what I need is the data for an artificial horizon (direction in the sense of east, north, ... would be a nice extra but is not strictly needed.) I don't understand any of it. None of the formulas I've tried work or seem to get even close. I should be able to tell if my display is facing up or down, and at which angle it is doing that, right? (Is the phone level, at a 30

Finding quaternion, representing transformation from one vector to another

我只是一个虾纸丫 提交于 2019-12-11 08:43:14
问题 Intro. Previously, I've asked a question on converting rgb triple to quaternion. After that question I've managed to get unit quaternions, but I am in doubt of their internal structure. There was no easy way to operate them, and to separate luma and chroma , since that were quaternions of unit length. According to my feeling about it, luminance should be encoded in the either real part, or a whole magnitude; And color " chroma " information should be encoded in the imaginary part. Today I've

quaternion creation by spherical coords in numpy

回眸只為那壹抹淺笑 提交于 2019-12-11 06:01:56
问题 While trying to understand the usage the quaternion extension of numpy, I saw that import numpy as np import quaternion as q theta = np.pi * 1.0 / 3.0 phi = 0.0 print(q.from_spherical_coords(theta,phi)) prints out (quaternion(0.866025403784439, -0, 0.5, 0)) This quaternion is a 60 degrees rotation around Y axis, but I expected a 60 degrees rotation around Z axis only, since phi is 0.0. Have theta and phi changed with respect to source files or am I missing something? Thanks for any help. 回答1:

How can I flip a sprite of an AI enemy character to face the direction its moving in?

拟墨画扇 提交于 2019-12-11 05:59:40
问题 I'm trying to make a patrolling AI character that will move from point to point. The patrol part works perfectly. However, the problem is that the sprite only faces right. When it turned the sprite stays facing the same direction. I have tried to change the transform rotation using transform.rotate , transform.rotation , transform.Quaternion and making a variable to store the rotation value yet they all kick errors back. The errors are usually made from the rotate/rotation functions not being

java 3D rotation with quaternions

﹥>﹥吖頭↗ 提交于 2019-12-11 04:38:25
问题 I have this method for rotating points in 3D using quaternions, but it seems not to work properly: public static ArrayList<Float> rotation3D(ArrayList<Float> points, double angle, int xi, int yi, int zi) { ArrayList<Float> newPoints = new ArrayList<>(); for (int i=0;i<points.size();i+=3) { float x_old = points.get(i); float y_old = points.get(i+1); float z_old = points.get(i+2); double w = Math.cos(angle/2.0); double x = xi*Math.sin(angle/2.0); double y = yi*Math.sin(angle/2.0); double z = zi

Rotation order for eulers getPitch(), getRoll(), getYaw() from Quaternion in libgdx?

柔情痞子 提交于 2019-12-11 03:41:10
问题 When transforming a quaternion to Euler Angles, usually there has to be a order in which the axes are rotated, like in this visualization. How does it work for libgdx? The Quaternion class has the functions getRoll(): Math.asin(MathUtils.clamp(2f * (w*x - z * y), -1f, 1f)) : (float)pole * MathUtils.PI * 0.5f;` getPitch(): Math.asin(MathUtils.clamp(2f * (w*x - z * y), -1f, 1f)) : (float)pole * MathUtils.PI * 0.5f;` getYaw(): ` MathUtils.atan2(2f * (y * w + x * z), 1f - 2f * (y * y + x * x)) :

OpenGL camera - View matrix from quaternion behaves incorrectly and pitch is too restricted

Deadly 提交于 2019-12-11 02:05:00
问题 I'm creating the view matrix for my camera using its current orientation (quaternion) and its current position. void Camera::updateViewMatrix() { view = glm::gtx::quaternion::toMat4(orientation); // Include rotation (Free Look Camera) view[3][0] = -glm::dot(glm::vec3(view[0][0], view[0][1], view[0][2]), position); view[3][1] = -glm::dot(glm::vec3(view[1][0], view[1][1], view[1][2]), position); view[3][2] = -glm::dot(glm::vec3(view[2][0], view[2][1], view[2][2]), position); // Ignore rotation