Guest User

Untitled

a guest
Dec 24th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public class Punkt {
  2.  
  3. final private double x;
  4. final private double y;
  5.  
  6. public Punkt(double x, double y) {
  7. this.x = x;
  8. this.y = y;
  9. }
  10.  
  11. public Punkt przesuniecie(double a, double b) {
  12. return new Punkt(x+a, y+b);
  13. }
  14. public double odlegloscOdPocz() {
  15. return Math.sqrt(x*x + y*y);
  16. }
  17. public double odlegloscOdPunktu(Punkt p){
  18. return Math.sqrt(Math.pow(p.x - x , 2) + Math.pow(p.y - y , 2));
  19. }
  20. public Punkt wzgledemOdcietej(){
  21. return new Punkt(x , -y);
  22. }
  23. public Punkt wzgledemRzednej(){
  24. return new Punkt(-x , y);
  25. }
  26. public Punkt wzgledemPoczatku(){
  27. return new Punkt(-x , -y);
  28. }
  29. public double odlegloscOdOX(){
  30. return Math.abs(y);
  31. }
  32. public double odlegloscOdOY() {
  33. return Math.abs(x);
  34. }
  35. public Punkt obrotLewo(double kat){
  36. double k = Math.toRadians(kat);
  37. return new Punkt(( (x * Math.cos(k)) - (y * Math.sin(k))) ,( (x * Math.sin(k)) + (y * Math.cos(k))));
  38. }
  39. public String toString() {
  40. return "(" + x + ", " + y + ")";
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment