@Test public void confined() { Vector a = new Vector(10, 50); Assert.assertEquals(a.confined(0, 100, 0, 100), a); Assert.assertEquals(a.confined(20, 100, 60, 100), new Vector(20, 60)); Assert.assertEquals(a.confined(0, 5, 0, 10), new Vector(5, 10)); Assert.assertEquals(a.confined(0, 100, 0, 10), new Vector(10, 10)); }
public Vector confined(double minX, double maxX, double minY, double maxY) { double newx = Math.min(Math.max(x, minX), maxX); double newy = Math.min(Math.max(y, minY), maxY); return new Vector(newx, newy); }
Vector implements Serializable { public Vector confined(double minX, double maxX, double minY, double maxY) { double newx = Math.min(Math.max(x, minX), maxX); double newy = Math.min(Math.max(y, minY), maxY); return new Vector(newx, newy); } }
Vector implements Serializable { public Vector confined(double minX, double maxX, double minY, double maxY) { double newx = Math.min(Math.max(x, minX), maxX); double newy = Math.min(Math.max(y, minY), maxY); return new Vector(newx, newy); } Vector(double x, double y);  Vector(); }
Vector implements Serializable { public Vector confined(double minX, double maxX, double minY, double maxY) { double newx = Math.min(Math.max(x, minX), maxX); double newy = Math.min(Math.max(y, minY), maxY); return new Vector(newx, newy); } Vector(double x, double y);  Vector(); static Vector fromVertexPosition(EPGMVertex v); void setVertexPosition(EPGMVertex v); Vector sub(Vector other); Vector add(Vector other); Vector mul(double factor); Vector div(double factor); double distance(Vector other); double scalar(Vector other); Vector clamped(double maxLen); Vector normalized(); double magnitude(); Vector confined(double minX, double maxX, double minY, double maxY); double angle(Vector other); Vector rotate(double angle); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); double getX(); void setX(double x); double getY(); void setY(double y); Vector set(double x, double y); Vector set(Vector other); Vector reset(); Vector copy(); Vector mSub(Vector other); Vector mAdd(Vector other); Vector mMul(double factor); Vector mDiv(double factor); Vector mClamped(double maxLen); Vector mNormalized(); Vector mConfined(double minX, double maxX, double minY, double maxY); Vector mRotate(double angle); }
Vector implements Serializable { public Vector confined(double minX, double maxX, double minY, double maxY) { double newx = Math.min(Math.max(x, minX), maxX); double newy = Math.min(Math.max(y, minY), maxY); return new Vector(newx, newy); } Vector(double x, double y);  Vector(); static Vector fromVertexPosition(EPGMVertex v); void setVertexPosition(EPGMVertex v); Vector sub(Vector other); Vector add(Vector other); Vector mul(double factor); Vector div(double factor); double distance(Vector other); double scalar(Vector other); Vector clamped(double maxLen); Vector normalized(); double magnitude(); Vector confined(double minX, double maxX, double minY, double maxY); double angle(Vector other); Vector rotate(double angle); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); double getX(); void setX(double x); double getY(); void setY(double y); Vector set(double x, double y); Vector set(Vector other); Vector reset(); Vector copy(); Vector mSub(Vector other); Vector mAdd(Vector other); Vector mMul(double factor); Vector mDiv(double factor); Vector mClamped(double maxLen); Vector mNormalized(); Vector mConfined(double minX, double maxX, double minY, double maxY); Vector mRotate(double angle);  }