How can I calculate rotation angles from a 3D vector without a rotation matrix?

Click For Summary
SUMMARY

The discussion focuses on calculating rotation angles from a 3D velocity vector in a Java applet without using a rotation matrix. The user seeks to derive Euler angles directly from the velocity vector (x, y, z) for object rotation. Key insights include the suggestion to explore quaternions for simplifying calculations and the acknowledgment that while rotation matrices are intuitive, they may not be necessary for this specific task. The user’s pseudo-code illustrates the intended approach for applying the calculated angles to rotate the object.

PREREQUISITES
  • Understanding of 3D vectors and their components (x, y, z)
  • Familiarity with Euler angles and their application in 3D rotations
  • Basic knowledge of Java programming and applet development
  • Awareness of quaternions and their role in 3D transformations
NEXT STEPS
  • Research how to calculate Euler angles from a 3D vector directly
  • Learn about quaternion mathematics and their application in 3D rotations
  • Explore the use of rotation matrices in conjunction with Euler angles
  • Investigate libraries for 3D transformations in Java, such as Java 3D or LWJGL
USEFUL FOR

Game developers, 3D graphics programmers, and anyone involved in object rotation and transformations in Java applications will benefit from this discussion.

112358
Messages
1
Reaction score
0
Hello folks!

So, I'm working on a java applet where I want to rotate an object to point in the direction that it is moving. I have its velocity stored as a 3D vector (x,y,z) and I am using a 3D library that allows for rotation on any axis (x,y, or z).

It's my understanding that I need to calculate the Euler angles for rotation along all 3 axes. I've found a lot of help online for calculating Euler angles from a rotation matrix. My issue is that I don't have a rotation matrix, i just have the velocity vector of the object. Can anyone help me understand how to calculate rotation angles from a 3D vector? Do I need to first calculate a rotation matrix and then calculate Euler angles?

My pseudo-code for what I am attempting is as follows:

angle1 = getXRotation(velocity);
angle2 = getYRotation(velocity);
angle3 = getZRotation(velocity);

translate(location)
rotateX(angle1)
rotateY(angle2)
rotateZ(angle3)
draw object!

Thanks all!
 
Mathematics news on Phys.org
Try to search quaternion, SU(3), unit complex number, etc. Quaternion may help you to simplify a lot of calculation.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 20 ·
Replies
20
Views
4K