// for AlgoElement @Override protected void setInputOutput() { input = new GeoElement[2]; input[0] = path.toGeoElement(); input[1] = point.toGeoElement(); setOutputLength(1); setOutput(0, (GeoElement) P); setDependencies(); // done by AlgoElement }
@Override public final void compute() { if (input[0].isDefined() && point.isDefined()) { if (path instanceof GeoFunction) { Function fun = (Function) ((GeoFunction) path).getFunction().deepCopy(kernel); Coords coords = point.getCoordsInD2(); double val = AlgoDistancePointObject.getClosestFunctionValueToPoint( fun, coords.getX(), coords.getY()); ((GeoPoint) P).setCoords(val, fun.evaluate(val), 1.0); } else { setCoords(); path.pointChanged(P); } P.updateCoords(); } else { P.setUndefined(); } }