mathematics – Rotate quaternion around plane normal

How can one rotate a quaternion so that the rotation is around a plane normal?

A graphic/diagram I made below gives more detail about what exactly I am implying. Note that the tip of the quaternions in the diagram are that of the quaternions local, upwards direction, symbolizing roll (the quaternion’s w component).

Rotate quaternion around plane normal

English describing the diagram:

The rotation is around plane normal (vector) N with amount θ. The global axes are X, Y, and Z (Y is up). The plane normal and quaternion are both in global space. Notice how the beginning and end of the operation does not use any reference to the global axes, only the plane.

The angle between the start quaternion (q) and end quaternion (q’) and the plane is equal (a = a’). If you were to draw lines from the tips of the quaternions to the plane, the angles of intersection would be equal. In other words, the roll of the quaternions are preserved in relation to that of the plane.

mathematics – Exchange of Y and Z in the quaternion

I convert between coordinate systems where Z is the vertical axis in one, and Y in another. I have the rotation values ​​represented as a quaternion.

I see this related problem, but it changes hands (DirectX and OpenGL): Changing axes and hands of a quaternion?

How could I exchange these values? I prefer not to convert to vector3, modify and reconvert.

of geographic coordinates – Calculation of body frame angles (Euler angles) between reference frames using quaternion rotation

I have read a lot of good information on how to rotate a vector in space using the rotation of the quaternion, i.e. RPR & # 39; where R & R & # 39; are quaternions and P is a vector i, j, k.

My question differs in that I have a certain body orientation described by the euler yaw, pitch and roll angles that I wish to rotate using the same quaternionic approach. For example, let's say I have an airplane in an ECEF coordinate frame with Yaw = -120, Pitch = 50, Roll = 30 degrees. Now I want to change the coordinate systems to ECI or NED. Finding the rotation matrix for weft transformation in the form of a direct cosine matrix or a quaternion is quite easy, but how to rotate pitch and yaw roll using quaternions as they are not a vector in space as described in the links below.

In particular, I found these links useful for describing something similar to what I want to do.

How to rotate a vector of a unitary quaternion?

https://www.youtube.com/watch?v=zjMuIxRvygQ -> 3brown1blue video on quaternions

I apologize if the question is redundant, this is my first post and not my area of ​​expertise. Any help is greatly appreciated!

opengl – GLM conversion of euler angles to quaternion and back does not hold

I am trying to convert the orientation of an OpenVR controller that I have stored as glm::vec3 Euler angles in a glm::fquat and back, but I get extremely different results and the behavior in the game is just wrong (difficult to explain, but the orientation of the object behaves normally for a small range of angles, then switches in strange axes).

Here is my conversion code:

// get `orientation` from OpenVR controller sensor data

const glm::vec3 eulerAnglesInDegrees{orientation(PITCH), orientation(YAW), orientation(ROLL)};
debugPrint(eulerAnglesInDegrees);

const glm::fquat quaternion{glm::radians(eulerAnglesInDegrees)};
const glm::vec3 result{glm::degrees(glm::eulerAngles(quaternion))};
debugPrint(result);

// `result` should represent the same orientation as `eulerAnglesInDegrees`

I would expect eulerAnglesInDegrees and result be either the same representations, or equivalent representations of the same orientation, but this is apparently not the case. Here are some examples of values ​​I get printed:

39.3851 5.17816 3.29104 
39.3851 5.17816 3.29104 

32.7636 144.849 44.3845 
-147.236 35.1512 -135.616 

39.3851 5.17816 3.29104 
39.3851 5.17816 3.29104 

32.0103 137.415 45.1592 
-147.99 42.5846 -134.841 

As you can see above, for some orientation ranges, the conversion is correct, but for others it is completely different.

What am i doing wrong?

I looked at the existing questions and tried a few things, including trying all of the possible rotation orders listed here, conjugating the quaternion and other random things like reversing the pitch / yaw / roll. Nothing has given me the expected result.

How can I convert euler angles to quaternions and back, representing the original orientation, using glm?


Some other examples of discrepancies:

original:      4; 175;   26; 
computed:   -175;   4; -153; 
difference:  179; 171;  179; 

original:     -6; 173;   32; 
computed:    173;   6; -147; 
difference: -179; 167;  179; 

original:      9; 268;  -46; 
computed:   -170; -88;  133; 
difference:  179; 356; -179; 

original:    -27; -73;  266; 
computed:    -27; -73;  -93; 
difference:    0;   0;  359; 

original:    -33; 111;  205; 
computed:    146;  68;   25; 
difference: -179;  43;  180; 

I tried to find a pattern to fix the finale computed results, but there does not seem to be an easy one to identify.


GIF + behavior video:

Video clip


Visual representation of my current intuition / understanding:

Visual diagram

  • The image above shows a sphere, and I'm in the center. When I point the gun towards the green half of the sphere, the orientation is correct. When I aim the gun at the red half of the sphere, it's incorrect – it seems like every axis is reversed, but I'm not 100% sure that it is.

Math – Find a quaternion of rotation from an orthonormal basis?

Given three unitary 3D vectors $ a $, $ b $, $ c $ such as:

$ a times b = c $

$ b times c = a $

$ c times a = b $

(that is to say $ a, b, c $ for men orthonormal basis)

How do you calculate a unit quartile $ q $ so that the product of the sand width (i.e. rotation) of $ q $ the (1,0,0) is $ a $, (0,1,0) is $ b $ and (0,0,1) is $ c $ ?

quaternion – Smoothing from Slerp to Slerp

p0 ------- p1 ------- p2

I am trying to successfully slip between 2 points (p0-p1; p1-p2). But the transition between two slerped angles (p1_in-p1_out) doesn't match, and that sounds shocking

Video of his appearance:

the green squares are points, the position and the angle between each are interpolated.

The problem is most visible at the second 6.00

I have tried hermitite splines, although this reduces the effect, it is still visible.

I tried to convert Catmull-Rom to use it with quaternions by simply adding the 4th index to the vector functions. This works perfectly, except on certain occasions, where some are interpolated from the wrong (long) "path", which switches the view between these points. I tried to line up, didn't help.

The other SO questions related to slerp do not ask this question, and I could not get usable answers from some questions on 4-point slerps.

Is this a common problem, do I supervise something?

Thank you

What is the convex shell of the quaternion symmetries of the three-dimensional cube?

It is well known that there are exactly five regular three-dimensional convex polyhedra, called Platonic solids.
In 1852 the Swiss mathematician Ludwig Schlafli discovered that there were exactly six regular 4 convex polytopes (the generalization of
4-dimensional polyhedra) and that, for dimensions 5 and above, there are only three!

The six 4 regular polytopes are:

NAME                    VERTEXES   EDGES   FACES  CELLS
Hypertetrahedron              5      10      10      5
Hypercube                    16      32      24      8
Hyperoctahedron               8      24      32     16
24-cell                      24      96      96     24
Hyperdodecahedron           600    1200     720    120
Hypericosahedron            120     720    1200    600

The simplest to describe are the first two:
a model for the hypertetrahedron can be obtained as the convex shell of the canonical base in $ mathbb R ^ 5 $ (hence a
4-dimensional object), while a model for the hypercube is the Cartesian product $ (0, 1) times (0, 1) times (0, 1) times (0,
1) $
.

As in the case of 3 dimensions, the dual of a regular 4-polytope is also a regular 4-polytope and it turns out that the regular six
The 4-polytopes found by Schlafli are linked to each other via duality as follows.

Hypetetrahedron    <->   Itself
24-cell            <->   Itself
Hypercube          <->   Hyperoctahedron
Hyperdodecahedron  <->   Hypericosahedron

This means that it is enough to describe the 24 cells and the hypericosahedron to be all known. In other words:

Hypertetrahedron    =  convex hull of the canonical basis in 5 dimensions
Hypercube           =  (0,1)x(0,1)x(0,1)x(0,1)
Hyperoctahedron     =  dual of the hypercube
Hyperdodecahedron   =  dual of the hypericosahedron
24-cell                ???
Hypericosahedron       ???

The description of the last two 4-polytopes above can be obtained by considering the quaternions $ mathbb Q $.
visualization $ mathbb R ^ 3 $ in $ mathbb Q $ via the card
$$ (x, y, z) mapsto xi + yj + zk, $$
it is well known that each quaternion
$ q $, with $ Green q Green = 1 $, give a rotation $ R_q $ sure $ mathbb R ^ 3 $ via the formula
$$
R_q (v) = qvq ^ {- 1}, quad forall v in mathbb R ^ 3.
$$

In fact the correspondence $ q mapsto R_q $ is a double coating of $ N / A (3) $ by the unitary sphere $ mathbb Q $.

leasing $ P_ {20} $ be the icosahedron $ mathbb R ^ 3 $, Take into account quaternionic symmetries of $ P_ {20} $, which I will write as
$ mathbb {QS} (P_ {20}) $, defined as the
set of all unitary quaternions $ q $ such as $ R_q $ leaves $ P_ {20} $
invariant. In symbols
$$
mathbb {QS} (P_ {20}) = {q in mathbb Q: Vert q Vert = 1, R_q (P_ {20}) = P_ {20} }.
$$

Well, the convex shell of $ mathbb {QS} (P_ {20}) $ in $ mathbb R ^ 4 $ proves to be a model for the hypericosahedron!

Since the symmetries of a regular polyhedron are the same as the symmetries of its dual, it is clear that the symmetries
of $ P_ {12} $, the dodecahedron, is nothing new: the convex shell of $ mathbb {QS} (P_ {12}) $ is just another model for the
hypericosaèdre.

Go to the tetrahedron (double auto), call it $ P_4 $, the convex shell of $ mathbb {QS} (P_ {4}) $ give a model for the
4 remaining polytopes, namely the 24 cells, completing the description of the six 4 Schlafli polytopes.

Question: What is the convex shell of the quaternion symmetries of the 3-dimensional cube?

If I am not mistaken, this polytope 4 has 48 vertices and 144 edges, so it is not in Schlafli's list and therefore cannot be regular.

quaternion – Calculate the orientation of GameObject in the custom coordinate system in Unity

I'm trying to build a custom coodinate system. To be more precise, the user chooses three points on the screen to define the coordinate system. The first is the origin, the second is used to build the OX axis, the third OZ and the last OY. The system is properly constructed. The axes are perpendicular to each other.

Once this coordinate system is built, I need to convert the orientation and position of objects placed on the screen from world space to this particular world space. To do this, I tried the solution proposed from here 1. It seems to work, but only for the post. The orientation seems not to change at all.

For example, if I place a cube at (0, 0, 0) without rotating it in world space, in my own coordinate system, it must also be at (0, 0, 0) and it does not should not be rotated relative to my own coordinate system. So the cube in my coordinate system should have a rotation relative to the world space. However, in reality, my code places the cube at my own origin, but does not rotate it accordingly.

In the image below, the first coordinate system (the smallest) is my own system. The other is of world origin. We can see that the WorldObject cube is placed at (0, 0, 0) with rotation (0, 0, 0). The OwnObject should be the representation of WorldObject in my system. We can see that the position has changed, but not the rotation.

My question is how can I rotate the second cube accordingly? I tried to define the rotation of the cube to be the orientation of the structure proposed in this solution 1, but it did not seem to rotate correctly. I also tried to use Quaternion.LookRotation, but it didn't work either.

enter description of image here
1 How to create a custom set of coordinates based on two points in Unity?

Unity – Rotate an object on itself, from one random Quaternion to another

I have a situation:
I have a 3D object in the world. say a sphere.
I have 2 random directional vectors: vector A and vector B:
enter the description of the image here

My question is: how to rotate in time my object, from A to B?
Vector A is important: I do not just want to turn the front of the object forward towards B.

I know I can use the vector3 function C = Vector3.SmoothDamp (…) in the unit for lerp between my 2 vectors A & B.

but then ok, I have vector3 C, how to apply the rotation of my object to C?
if you do not want to do:
gameObject.transform.forward = C;

I want something like:
gameObject.transform.rotation = SomeQuaternion (C, initial rotation A).
or something.

Thanks for the help!

PS: I do not want to be parent / non parent gameObject or something like that, I want the math answer, using Quaternion.

Aggressive Geometry – Reference Request: Shimura Curve and Quaternion Algebra

Let $ F $ to be a totally real field, and $ D $ to be a quaternion algebra on $ F $ which is divided to exactly an infinite prime number of $ F $, then we have the associated quaternionic Shimura curve $ Sh $ more than $ F $ which is of abelian type and not of PEL type in general if $ F not = mathbb Q $. People usually introduce / define the Shimura Curve in this way.

Is it true that $ 1 $Does Shimura variety have the form above? In particular, everything $ 1 $Shimura variety is abelian type? I can not find a good reference for the proof.