Rotate 1 plane in 3d space to be parallel to another

Click For Summary
SUMMARY

This discussion focuses on the mathematical problem of rotating a 3D shape (Shape A) to align one of its faces parallel to the nearest face of another shape (Shape B). The user encounters issues with alternating rotations due to the use of Euler angles, which can represent multiple valid orientations. The solution involves using quaternions for rotation, specifically constructing a quaternion from the cross product of the normal vectors of the two shapes. The formula provided for the quaternion transformation is q = cos(θ/2) + (a × b / |a × b|) sin(θ/2), where θ is the angle between the two normal vectors.

PREREQUISITES
  • Understanding of 3D geometry and vector mathematics
  • Familiarity with quaternions and their application in 3D rotations
  • Knowledge of Euler angles and their limitations in representing 3D orientations
  • Ability to perform vector operations such as dot and cross products
NEXT STEPS
  • Study quaternion mathematics and their application in 3D transformations
  • Learn about the limitations of Euler angles in 3D rotations
  • Explore vector normalization and its importance in quaternion calculations
  • Implement a function to convert between Euler angles and quaternions
USEFUL FOR

This discussion is beneficial for computer graphics developers, game developers, and anyone involved in 3D modeling or simulation who needs to understand and implement 3D rotations accurately.

sparkzbarca
Messages
7
Reaction score
0
I'm not sure if this is the right forum.

I'm actually trying to solve this for a computer program

given shape A and shape B i'd like to rotate shape A so a given face is parallel to the nearest face of shape B

http://postimage.org/image/shb6kyv6d/

attached image but i can't see it. the link
http://postimage.org/image/shb6kyv6d/

i've honestly been working on this problem for hours.
When I run the program The issue i have is it keep keeps alternating between 4 rotations or I can only get the same face everytime to rotate towards it like.
cross Shape A's right with shape B's normal and it produces a plane perpindicular to shape B's plane but the same side of shape A always faces it, not just the nearest.

If i try and change it I sometimes end up with the shape shifting between 4 different rotations.
Presumably the 4 quadrants I think because I'm giving it euler angles and they can represent one of 4 valid rotations but I've no idea how to convert that angle into a single quaternion rotation.

I have the quaternion of each shape but I don't understand quaternions or how to change them properly.

Any help would be much appreciated on what the general function should look like.
I think part of the problem is not knowing what information exactly i need to perform the rotation.
 
Physics news on Phys.org
The quaternion of each shape? The quaternions describing their orientation with respect to a reference direction?

You know the two normal vectors, so this is not a difficult computation. You can find the angle between the vectors by either the dot or cross product.

Find the unit vector result of the cross product, and this is the "imaginary" that you use to build the quaternion.

That is to say, if your normal vectors are a,b, then the quaternion that transforms a to b is

q = \cos \frac{\theta}{2} + \frac{a \times b}{|a \times b|} \sin \frac{\theta}{2}

where \sin \theta = \frac{a \times b}{|a||b|}.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 15 ·
Replies
15
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K