private void intersect( PlaneNormal3D_F64 left , PlaneNormal3D_F64 right , PlaneNormal3D_F64 top , Point3D_F64 p ) { PlaneGeneral3D_F64 leftG = UtilPlane3D_F64.convert(left,null); PlaneGeneral3D_F64 rightG = UtilPlane3D_F64.convert(right,null); // find intersection of all three planes if( !Intersection3D_F64.intersect(leftG,rightG,line) ) throw new RuntimeException("left and right plane's don't intersect"); Intersection3D_F64.intersect(top,line,p); System.out.println("Intersection of all planes: "+p); }
@Override public boolean fitModel(List<Point3D_F64> dataSet, PlaneGeneral3D_F64 initial, PlaneGeneral3D_F64 found) { if (!alg.svd(dataSet, planeNorm.p, planeNorm.n)) return false; UtilPlane3D_F64.convert(planeNorm, found); return true; } }
public void testAgainstUnweighted(int n, int k) { Point3D_F64 origin = new Point3D_F64(); Vector3D_F64 normal = new Vector3D_F64(); List<Point3D_F64> allPoints = getRandomPoints(n); List<Point3D_F64> selectedPoints = new ArrayList<Point3D_F64>(); double[] weights = new double[n]; while (selectedPoints.size() < k) { int index = rand.nextInt(allPoints.size()); Point3D_F64 point = allPoints.get(index); if (!selectedPoints.contains(point)) { selectedPoints.add(point); weights[index] = 1; } } new FitPlaneWeighted3D_F64().svd(allPoints, weights, origin, normal); PlaneGeneral3D_F64 weightedFit = UtilPlane3D_F64.convert(new PlaneNormal3D_F64(origin, normal), null); new FitPlane3D_F64().svd(selectedPoints, origin, normal); PlaneGeneral3D_F64 fit = UtilPlane3D_F64.convert(new PlaneNormal3D_F64(origin, normal), null); assert(epsilonEquals(weightedFit, fit, eps)); }
public static List<PlaneGeneral3D_F64> fit(List<PlaneGeneral3D_F64> planes, List<Point3D_F64> allPoints, ScoringFunction<PlaneGeneral3D_F64, Point3D_F64> scorer, int iterations) { FitPlaneWeighted3D_F64 fitter = new FitPlaneWeighted3D_F64(); Point3D_F64 fitOrigin = new Point3D_F64(); Vector3D_F64 fitNormal = new Vector3D_F64(); double[][] weights = new double[planes.size()][allPoints.size()]; for (; iterations > 0; iterations--) { getWeights(weights, planes, allPoints, scorer); planes.clear(); for (int i = 0; i < weights.length; i++) { fitter.svd(allPoints, weights[i], fitOrigin, fitNormal); planes.add(UtilPlane3D_F64.convert(new PlaneNormal3D_F64(fitOrigin, fitNormal), null)); } } return planes; }
@Override public boolean generate(List<PointVectorNN> dataSet, PlaneGeneral3D_F64 output) { PointVectorNN pa = dataSet.get(0); PointVectorNN pb = dataSet.get(1); PointVectorNN pc = dataSet.get(2); // find the plane's normal vector GeometryMath_F64.sub(pa.p, pb.p, a); GeometryMath_F64.sub(pa.p, pc.p, b); GeometryMath_F64.cross(a, b, n); n.normalize(); if (!checkModel(pa, pb, pc)) return false; // asume the first point is one the plane planeNormal.n = n; planeNormal.p = pa.p; UtilPlane3D_F64.convert(planeNormal, output); return check.valid(output); }
UtilPlane3D_F64.convert(pi,pi_gen);
UtilPlane3D_F64.convert(pi,pi_gen);