title: why sqrt times cos return wrong value
body: <p>I am coding a calculater that find the coordinates of a rotated point. (inspired from math tutorial on youtube <a href="http://www.youtube.com/watch?v=NQduSvpTyhs" rel="nofollow">http://www.youtube.com/watch?v=NQduSvpTyhs</a>)</p>
  
  <p>the part where im stuck is the return of ansx and ansy. instead of 4.0 and 3.6 it returns incorect answer. (Nouvelles coordoner : -3.0853888289108733,-4.413657867849748)</p>
  
  <p>I cant understand what is happening wrong in those 2 lines ...</p>
  
  <pre><code>static void tourner()
      {
          Scanner tournsc = new Scanner(System.in);
          double coordx, coordy, roattiondeg, ansx, ansy, angle, triangleh, newangle;
          //Test input : X 5, Y 2, rotation deg 20
          System.out.println("Coord X :");
          coordx = tournsc.nextInt();
          System.out.println("Coord Y :");
          coordy = tournsc.nextInt();
  
          System.out.println("Degre : ");
          roattiondeg = tournsc.nextInt();
  
          triangleh = ((Math.pow(coordx, 2)) + (Math.pow(coordy, 2)));
  
          angle = Math.toDegrees(Math.atan(coordy/coordx));
          newangle = roattiondeg + angle;
          ansx = Math.sqrt(triangleh)*Math.cos(newangle);
          ansy = Math.sqrt(triangleh)*Math.sin(newangle);
          System.out.println("Nouvelles coordoner : " + ansx + "," + ansy);
  
  
      }
  </code></pre>
  
  <p>Question : why ansx and ansy give good answer on my real life calculater but wrong in the program?</p>
  
  <p>thx for helps.</p>