Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. /**
  2. * Created by Ovidio on 8/27/2016.
  3. */
  4. public class Vector2D {
  5. private float x;
  6. private float y;
  7.  
  8. public Vector2D() {
  9. x = 0;
  10. y = 0;
  11. }
  12.  
  13. public Vector2D(float x, float y) {
  14. this.x = x;
  15. this.y = y;
  16. }
  17.  
  18. public void multConst(float c) {
  19. x *= c;
  20. y *= c;
  21. }
  22.  
  23. public void divConst(float c) {
  24. x /= c;
  25. y /= c;
  26. }
  27.  
  28. public void sum(Vector2D v) {
  29. x += v.getX();
  30. y += v.getY();
  31. }
  32.  
  33. public void substract(Vector2D v) {
  34. x -= v.getX();
  35. y -= v.getY();
  36. }
  37.  
  38. public float getX(){
  39. return x;
  40. }
  41. public float getY() {
  42. return y;
  43. }
  44. public void setX(float x) {
  45. this.x = x;
  46. }
  47. public void setY(float y) {
  48. this.y = y;
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement