Refine search
/** * Is the polygon closed (i.e. is the last vertex equal to the first)? * * @return true if closed; false if open */ public boolean isClosed() { if (points.size() > 0 && points.get(0).getX() == points.get(points.size() - 1).getX() && points.get(0).getY() == points.get(points.size() - 1).getY()) return true; return false; }
@Override public double computeError(Matrix h, List<? extends IndependentPair<? extends Point2d, ? extends Point2d>> data) { double error = 0; for (int i = 0; i < data.size(); i++) { final Point2d p1 = data.get(i).firstObject().transform(h); final Point2d p2 = data.get(i).secondObject(); final float dx = p1.getX() - p2.getX(); final float dy = p1.getY() - p2.getY(); error += dx * dx + dy * dy; } return error; }
@Override public void computeResiduals(List<? extends IndependentPair<Point2d, Point2d>> data, double[] errors) { for (int i = 0; i < data.size(); i++) { final Point2d p2_est = model.predict(data.get(i).firstObject()); final Point2d so = data.get(i).secondObject(); final float dx = so.getX() - p2_est.getX(); final float dy = so.getY() - p2_est.getY(); errors[i] = (dx * dx + dy * dy); } } }
private static RealVector toRealVector(List<? extends IndependentPair<? extends Point2d, ? extends Point2d>> data) { final double[] vec = new double[data.size() * 4]; for (int i = 0; i < data.size(); i++) { vec[i * 4 + 0] = data.get(i).firstObject().getX(); vec[i * 4 + 1] = data.get(i).firstObject().getY(); vec[i * 4 + 2] = data.get(i).secondObject().getX(); vec[i * 4 + 3] = data.get(i).secondObject().getY(); } return new ArrayRealVector(vec); }
@Override public void computeResiduals(List<? extends IndependentPair<Point2d, Point2d>> data, double[] errors) { for (int i = 0; i < data.size(); i++) { final Point2d p2_est = model.predict(data.get(i).firstObject()).transform(t1); final Point2d so = data.get(i).secondObject().transform(t2); final float dx = so.getX() - p2_est.getX(); final float dy = so.getY() - p2_est.getY(); errors[i] = (dx * dx + dy * dy); } } }
private synchronized void drawWhiteboard(MBFImage drawingPanel) { // drawingPanel.fill(RGBColour.WHITE); if (mode == MODE.MODEL || this.calibrationPointIndex < this.calibrationPoints.size()) { drawingPanel.fill(RGBColour.WHITE); final Point2d waitingForPoint = this.calibrationPoints.get(calibrationPointIndex).secondObject(); drawingPanel.createRenderer().drawShape(new Circle(waitingForPoint.getX(), waitingForPoint.getY(), 10), RGBColour.RED); } }
@Override public double calculateArea() { final double xb = vertices[1].getX() - vertices[0].getX(); final double yb = vertices[1].getY() - vertices[0].getY(); final double xc = vertices[2].getX() - vertices[0].getX(); final double yc = vertices[2].getY() - vertices[0].getY(); return 0.5 * Math.abs(xb * yc - xc * yb); }
private synchronized void drawWhiteboard(MBFImage drawingPanel) { // drawingPanel.fill(RGBColour.WHITE); if (mode == MODE.MODEL || this.calibrationPointIndex < this.calibrationPoints.size()) { drawingPanel.fill(RGBColour.WHITE); final Point2d waitingForPoint = this.calibrationPoints.get(calibrationPointIndex).secondObject(); drawingPanel.createRenderer().drawShape(new Circle(waitingForPoint.getX(), waitingForPoint.getY(), 10), RGBColour.RED); } }