@Test public void vectorBetween() throws Exception { Vector2D vectorBetween; F1 = GeometryFactory.createVector(0, 0); F2 = GeometryFactory.createVector(2, 0); minorAxis = 2; ellipse = GeometryFactory.createEllipse(F1, F2, minorAxis); point = GeometryFactory.createVector(1, 3); vectorBetween = ellipse.vectorBetween(point); Assert.assertEquals(0, vectorBetween.getXComponent(), PRECISION); Assert.assertEquals(1, vectorBetween.getYComponent(), PRECISION); ellipse = GeometryFactory.createEllipse(new Vector2D(10, 10), new Vector2D(1, 0), 1, 1); Assert.assertEquals(0, ellipse.getOrientation(), PRECISION); point = new Vector2D(12,12); closestPoint = ellipse.closestPoint(point); vectorBetween = ellipse.vectorBetween(point); Assert.assertEquals(2 - Math.sqrt(2)/2, vectorBetween.getXComponent(), PRECISION); Assert.assertEquals(2 - Math.sqrt(2)/2, vectorBetween.getYComponent(), PRECISION); }
public Vector2D vectorBetween(Vector2D point) { Vector2D closestPoint = closestPoint(point); return point.subtract(closestPoint); }
Ellipse2D { public Vector2D vectorBetween(Vector2D point) { Vector2D closestPoint = closestPoint(point); return point.subtract(closestPoint); } }
Ellipse2D { public Vector2D vectorBetween(Vector2D point) { Vector2D closestPoint = closestPoint(point); return point.subtract(closestPoint); } Ellipse2D(Vector2D center, Vector2D direction, double majorAxis, double minorAxis); }
Ellipse2D { public Vector2D vectorBetween(Vector2D point) { Vector2D closestPoint = closestPoint(point); return point.subtract(closestPoint); } Ellipse2D(Vector2D center, Vector2D direction, double majorAxis, double minorAxis); Vector2D closestPoint(Vector2D point); Vector2D vectorBetween(Vector2D point); Vector2D normal(Vector2D point); Vector2D getCenter(); void setCenter(Vector2D center); double getOrientation(); double getMajorAxis(); double getMinorAxis(); void translate(double x, double y); void translate(Vector2D vector); }
Ellipse2D { public Vector2D vectorBetween(Vector2D point) { Vector2D closestPoint = closestPoint(point); return point.subtract(closestPoint); } Ellipse2D(Vector2D center, Vector2D direction, double majorAxis, double minorAxis); Vector2D closestPoint(Vector2D point); Vector2D vectorBetween(Vector2D point); Vector2D normal(Vector2D point); Vector2D getCenter(); void setCenter(Vector2D center); double getOrientation(); double getMajorAxis(); double getMinorAxis(); void translate(double x, double y); void translate(Vector2D vector);  }