"adding" two angles

Ok, so I got two angles. One of them is the angle of the joystick, and the other is the angle of the camera. Camera angle. Now I want it to be, when I press the joystick, it takes the player away from the camera. How should I do it? And is there an easy way to do this in Java or Ardor3d?

edit: Here is the code of how I get my angles.

float camDegree = (float) Math.toDegrees(Math.atan2(
                     _canvas.getCanvasRenderer().getCamera().getLocation().getXf() - colladaNode.getTranslation().getXf(),
                     _canvas.getCanvasRenderer().getCamera().getLocation().getYf()) - colladaNode.getTranslation().getYf());

            player.angle = (float) Math.toDegrees(Math.atan2(padX, padY));
            Quaternion camQ = new Quaternion().fromAngleAxis(camDegree, Vector3.UNIT_Y);
+3
source share
1 answer

I have to say that I really do not understand your question, but it seems that this is about how to exercise control over the cameras using the joystick.

The most important piece of advice I can give you is that it’s better not to calculate angles, but to work directly with vectors.

, v ( , , ):

the look vector from a camera to a player can be resolved into vertical and horizontal components

, , , y , :

y= v - (v )

- , .

, y, - ( ):

x= v Γ—

the vectors x and y form a horizontal coordinate basis

, y - , ( ), x , ( ). :

x= x/| x |

Ε·= y/| y |

x Ε· . Jx Jy,

s (Jx x + Jy Ε·)

s - , .

( , !)

+8

Source: https://habr.com/ru/post/1777844/


All Articles