@Test public void vectorBetween() throws Exception { center = GeometryFactory.createVector(0, 0); direction = GeometryFactory.createVector(1, 0); width = 2; height = 6; rectangle = new Rectangle2D(center, direction, width, height); point = GeometryFactory.createVector(3, 2); Assert.assertEquals(1, rectangle.distanceBetween(point), PRECISION); point = GeometryFactory.createVector(-4, 2); Assert.assertEquals(Math.sqrt(2), rectangle.distanceBetween(point), PRECISION); point = GeometryFactory.createVector(3, 2); Vector2D between = rectangle.vectorBetween(point); Assert.assertEquals(0, between.getXComponent(), PRECISION); Assert.assertEquals(-1, between.getYComponent(), PRECISION); }
@Override public Vector2D vectorBetween(Vector2D point) { return this.rectangleAsSegments().vectorBetween(point); }
Rectangle2D extends Geometry2D { @Override public Vector2D vectorBetween(Vector2D point) { return this.rectangleAsSegments().vectorBetween(point); } }
Rectangle2D extends Geometry2D { @Override public Vector2D vectorBetween(Vector2D point) { return this.rectangleAsSegments().vectorBetween(point); } Rectangle2D(Vector2D center, Vector2D direction, double width, double height); }
Rectangle2D extends Geometry2D { @Override public Vector2D vectorBetween(Vector2D point) { return this.rectangleAsSegments().vectorBetween(point); } Rectangle2D(Vector2D center, Vector2D direction, double width, double height); @Override double distanceBetween(Vector2D point); @Override double minimalDistanceBetween(List<Vector2D> points); @Override Vector2D vectorBetween(Vector2D point); @Override ArrayList<Vector2D> getIntersection(Segment2D segment); @Override ArrayList<Vector2D> getIntersection(Polygon2D polygon); @Override ArrayList<Vector2D> getIntersection(Cycle2D segment); @Override boolean isOnCorners(Vector2D vector, double precision); @Override boolean isOnLines(Vector2D vector, double precision); @Override List<Vector2D> getVertices(); synchronized Segment2D rectangleAsSegments(); @Override List<Segment2D> getSegments(); @Override Vector2D getPointClosestToVector(Vector2D toVector); @Override double area(); @Override boolean contains(Vector2D point); @Override boolean contains(Vector2D point, Transform transform); @Override Mass createMass(double density); @Override double getRadius(); @Override double getRadius(Vector2D vector); @Override Vector2D getCenter(); @Override void rotate(double theta); @Override void rotate(double theta, double x, double y); @Override void rotate(double theta, Vector2D vector); @Override void translate(double x, double y); @Override void translate(Vector2D vector); }
Rectangle2D extends Geometry2D { @Override public Vector2D vectorBetween(Vector2D point) { return this.rectangleAsSegments().vectorBetween(point); } Rectangle2D(Vector2D center, Vector2D direction, double width, double height); @Override double distanceBetween(Vector2D point); @Override double minimalDistanceBetween(List<Vector2D> points); @Override Vector2D vectorBetween(Vector2D point); @Override ArrayList<Vector2D> getIntersection(Segment2D segment); @Override ArrayList<Vector2D> getIntersection(Polygon2D polygon); @Override ArrayList<Vector2D> getIntersection(Cycle2D segment); @Override boolean isOnCorners(Vector2D vector, double precision); @Override boolean isOnLines(Vector2D vector, double precision); @Override List<Vector2D> getVertices(); synchronized Segment2D rectangleAsSegments(); @Override List<Segment2D> getSegments(); @Override Vector2D getPointClosestToVector(Vector2D toVector); @Override double area(); @Override boolean contains(Vector2D point); @Override boolean contains(Vector2D point, Transform transform); @Override Mass createMass(double density); @Override double getRadius(); @Override double getRadius(Vector2D vector); @Override Vector2D getCenter(); @Override void rotate(double theta); @Override void rotate(double theta, double x, double y); @Override void rotate(double theta, Vector2D vector); @Override void translate(double x, double y); @Override void translate(Vector2D vector);  }