@Test public void closestPoint() throws Exception { F1 = GeometryFactory.createVector(0, 0); F2 = GeometryFactory.createVector(2, 0); minorAxis = 2; ellipse = GeometryFactory.createEllipse(F1, F2, minorAxis); point = GeometryFactory.createVector(1, 3); closestPoint = ellipse.closestPoint(point); Assert.assertEquals(1, closestPoint.getXComponent(), PRECISION); Assert.assertEquals(2, closestPoint.getYComponent(), PRECISION); ellipse = GeometryFactory.createEllipse(new Vector2D(10, 10), new Vector2D(1, 0), 1, 1); point = new Vector2D(12, 12); Assert.assertEquals(10+Math.sqrt(2)/2, ellipse.closestPoint(point).getXComponent(), PRECISION); Assert.assertEquals(10+Math.sqrt(2)/2, ellipse.closestPoint(point).getXComponent(), PRECISION); }
public Vector2D closestPoint(Vector2D point) { return null; }
Ellipse2D { public Vector2D closestPoint(Vector2D point) { return null; } }
Ellipse2D { public Vector2D closestPoint(Vector2D point) { return null; } Ellipse2D(Vector2D center, Vector2D direction, double majorAxis, double minorAxis); }
Ellipse2D { public Vector2D closestPoint(Vector2D point) { return null; } 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 closestPoint(Vector2D point) { return null; } 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);  }