fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import static java.lang.Math.*;
  7. class Vector
  8. {
  9. double x;
  10. double y;
  11.  
  12. Vector(double a, double b)
  13. {
  14. x = a;
  15. y = b;
  16. }
  17.  
  18. void add(Vector v)
  19. {
  20. x += v.x;
  21. y += v.y;
  22. }
  23.  
  24. void Rotate(double angle)
  25. {
  26. double s = sin(angle);
  27. double c = cos(angle);
  28.  
  29. x = x * c - y * s;
  30. y = x * s + y * c;
  31. }
  32.  
  33. }
  34.  
  35.  
  36.  
  37.  
  38. class Ideone
  39. {
  40. public static void main (String[] args) throws java.lang.Exception
  41. {
  42. Vector v = new Vector(1,1);
  43. v.Rotate(Math.PI / 2);
  44. System.out.println(v.x + " " + v.y);
  45. }
  46. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
-0.9999999999999999 -0.9999999999999998