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

Click For Summary
To rotate shape A so that a specific face is parallel to the nearest face of shape B, the user is struggling with the implementation in their computer program. They are experiencing issues with the rotation alternating between four positions and consistently aligning the same face, likely due to the use of Euler angles. The discussion suggests using quaternions for rotation, as they can provide a more stable representation. It is recommended to compute the angle between the normal vectors of the shapes using the dot or cross product, and to construct the quaternion based on these calculations. Understanding how to convert the angle into a quaternion is essential for achieving the desired rotation.
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 4 ·
Replies
4
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
Replies
1
Views
3K
Replies
9
Views
696
Replies
2
Views
3K