1

I'm trying to make some sort of 3D editor, and I'm trying to make an "orbit" tool, much like the one in Blender.

Now I'd like to know what the angle is. I used the code provided by José Pereda that can be found here, but I need the angles to be in the range from 0 to 2π. I cannot retrieve them from the acquired angles since the output values don't range from -π to π and are different for every output.

Also, the extracted angles need to be relative to each other, much like if you put 3 different Rotate transformations where every following one is relative to the preceding ones, preferably in YXZ order, since that's the order I use everywhere else, as well as the model format the editor is going to export into.

As requested, I have uploaded the part of the code that is relevant to the question on Pastebin. As far as I could tell from the printed values, the angles are relative to each other in XYZ order. For angle calculation, I use the snippet from the linked question:

public static Vec3d getAngle(Node n) {
    Transform T = n.getLocalToSceneTransform();
    double roll = Math.atan2(-T.getMyx(), T.getMxx());
    double pitch = Math.atan2(-T.getMzy(), T.getMzz());
    double yaw = Math.atan2(T.getMzx(), Math.sqrt(T.getMzy() * T.getMzy() + T.getMzz() * T.getMzz()));
    return new Vec3d(roll, pitch, yaw);
}

Just a quick notice, I have very little knowledge of matrices and their transformations, since that's something we'll be taking in our school next year, which makes it harder for me to understand.

Mysterious Wolf
  • 373
  • 1
  • 5
  • 22
  • 2
    Quack! Quack! Quack! – Sergey Grinev Mar 31 '18 at 19:44
  • Thank you, I don't know what I was thinking when writing the last sentence of the question. – Mysterious Wolf Apr 01 '18 at 07:41
  • 1
    Have you checked this [question](https://stackoverflow.com/questions/48850937/javafx-how-to-apply-yaw-pitch-and-roll-deltas-not-euler-to-a-node-in-respec)? It applies a new rotation to the previous rotated state. If this doesn't apply to you, please clarify more what you are asking. A short code snippet will be helpful. – José Pereda Apr 01 '18 at 09:01
  • I have checked the answer and I use the method provided. I have already done the part where I rotate the tool relative to all the previous rotations/the local axis, but now I need to get the global rotation angles. I added more explanation and cleaned the unnecessary information in the original post. – Mysterious Wolf Apr 01 '18 at 10:37
  • 2
    Without a code snippet that allows us to reproduce what you are doing, what you get and what is not working for you, it is really hard to give you a proper answer. – José Pereda Apr 01 '18 at 20:50

0 Answers0