Search code examples
javamathangleatan2

Java a way to get from an angle the atan2 value (alpha)?


  double dx = mx - px;
    double dy = my - py;
    double alpha = Math.atan2(dy, dx);
    float angle = (float) Math.toDegrees(alpha);
    angle += 10;

Now I want to convert the angle to the alpha value (atan2) is there a way how i can do that?

The purpose is that I have a game an want to fire bullets with a variation of the degree like a shotgun.


Solution

  • double newalpha = Math.toRadians(angle);