1

I have been trying to develop a program to calculate the Euler angle between 2 3D vectors, however after extensive research it appears this is far beyond my league. I have read about having to calculate dot products, slopes, runs and rises and so on, but none of these solutions appear to be what I am looking for. At this point I am quite confused whether or not I am looking for an Euler angle or if I should call it 'direction' instead, hence why the question contains both terms.

A bit of context: A friend and I are modding an old game and occasionally animation files have to made for objects to make them move throughout the map. So far however, we have always guessed the direction the object should be facing.

This image shows how the 3D system in this game is designed. Looking from the origin, the X-axis is left and right, the Y-axis is up and down and the Z-axis is forward and backward.

Here is a visual representation of my problem. The starting rotation of the island does not matter in this case. Let's say the island starts at coordinate (-1900 20 260) and I want to move the island to coordinate (-1988 33 185). My desired outcome is the XYZ-values of the angle the island should be facing while moving towards this coordinate. The island has to face (-1988 33 185) while moving towards it.

Here is a visual representation of my desired outcome. The angle I am looking for in this case is the designated angle in the screenshot. According to the game's system, if you are facing the same direction as the arrow facing the top of the screenshot, you are rotated (0° 0° 0°). Rotating counter-clockwise results in a positive angle around the Y-axis while rotating clockwise results in a negative angle.

How do I calculate the XYZ-values of the Euler angle according to the given example?

  • You're going to need to implement something like https://math.stackexchange.com/questions/974178/how-to-calculate-the-angle-between-2-vectors-in-3d-space-given-a-preset-function – morrowmh Sep 01 '20 at 20:40
  • Just represent your arrows using vectors, take their dot product, divide by the product of their magnitudes, and take an inverse cosine. That will give the angle between them. – morrowmh Sep 01 '20 at 20:43
  • You could even use unit vectors to make computations easier. Then you don't actually have to divide by the product of their magnitudes, since they would both have magnitude 1. – morrowmh Sep 01 '20 at 20:45
  • By the way... angles don't have XYZ values. An angle between two vectors would be something like $\pi/2$ radians, aka $90$ degrees. – morrowmh Sep 01 '20 at 20:49
  • I need the 3 Euler angles, so the XYZ of the rotation of the object, not just the angle between the vectors. Is the angle you are talking about the axis-angle by any chance and if that's the case, is there a way to convert it to the Euler angles? As I said, this math is far beyond my league. I'm a software developer and I have never seen any of this complex math. It just happens I ran into this for a hobby project. I also don't know unit vectors and the term magnitude. I haven't worked with this before. – Jumper Snipèra Sep 01 '20 at 22:41

0 Answers0