1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package me.hammerle.supersnuvi.math;
- public class Vector implements IVector
- {
- private float x = 0.0f;
- private float y = 0.0f;
-
- public Vector(float x, float y)
- {
- this.x = x;
- this.y = y;
- }
-
- public Vector()
- {
- this(0.0f, 0.0f);
- }
-
- public void setX(float x)
- {
- this.x = x;
- }
-
- public void setY(float y)
- {
- this.y = y;
- }
-
- public void set(float x, float y)
- {
- this.x = x;
- this.y = y;
- }
-
- public void set(Vector v)
- {
- set(v.x, v.y);
- }
-
- public void add(float x, float y)
- {
- this.x += x;
- this.y += y;
- }
-
- public void add(Vector v)
- {
- add(v.x, v.y);
- }
-
- public void sub(Vector v)
- {
- add(-v.x, -v.y);
- }
-
- public void addY(float y)
- {
- this.y += y;
- }
-
- public void addX(float x)
- {
- this.x += x;
- }
-
- public void mul(Vector v)
- {
- x *= v.x;
- y *= v.y;
- }
-
- public void mul(float fx, float fy)
- {
- x *= fx;
- y *= fy;
- }
- @Override
- public float getX()
- {
- return x;
- }
- @Override
- public float getY()
- {
- return y;
- }
- @Override
- public String toString()
- {
- return String.format("Vector(x = %f, y = %f)", x, y);
- }
- }
|