Refines P2 and P3 using SBA. View 1 is assumed to be P1 = [I|0]

@param listObs Observations from the three views
@param P2 camera matrix for view 2. modified
@param P3 camera matrix for view 3. modified
@return true if successful
480845
public boolean refine(List<AssociatedTriple> listObs , DMatrixRMaj P2 , DMatrixRMaj P3 )
	{
		CommonOps_DDRM.setIdentity(P1);
		initializeStructure(listObs, P2, P3);

		if( scale ) {
			scaler.applyScale(structure,observations);
		}

//		sba.setVerbose(System.out,0);
		sba.setParameters(structure,observations);
		sba.configure(converge.ftol,converge.gtol,converge.maxIterations);

		if( !sba.optimize(structure) ) {
			return false;
		}

		// save the results
		P2.set(structure.views[1].worldToView);
		P3.set(structure.views[2].worldToView);

		if( scale ) {
			// don't use built in unscaling function because it undoes scaling on points. Those are disposable
			scaler.pixelScaling.get(1).remove(P2,P2);
			scaler.pixelScaling.get(2).remove(P3,P3);
		}

		return true;
	}
1007499
public static <T extends Comparable<T>> int compareLists(List<T> list1, List<T> list2) {
    if (list1 == null && list2 == null)
      return 0;
    if (list1 == null || list2 == null) {
      throw new IllegalArgumentException();
    }
    int size1 = list1.size();
    int size2 = list2.size();
    int size = Math.min(size1, size2);
    for (int i = 0; i < size; i++) {
      int c = list1.get(i).compareTo(list2.get(i));
      if (c != 0)
        return c;
    }
    if (size1 < size2)
      return -1;
    if (size1 > size2)
      return 1;
    return 0;
  }
795760
@SuppressWarnings("unused") // called through reflection by RequestServer
  public ModelsV3 list(int version, ModelsV3 s) {
    Models m = s.createAndFillImpl();
    m.models = Model.fetchAll();
    return (ModelsV3) s.fillFromImplWithSynopsis(m);
  }
1364663
def issubset(list1, list2):
    
    n = len(list1)
    for startpos in range(len(list2) - n + 1):
        if list2[startpos:startpos+n] == list1:
            return True
    return False
87523
static boolean pointDisjointEnvelope_(Point2D pt_a, Envelope2D env_b,
			double tolerance, ProgressTracker progress_tracker) {
		Envelope2D env_b_inflated = new Envelope2D();
		env_b_inflated.setCoords(env_b);
		env_b_inflated.inflate(tolerance, tolerance);
		return !env_b_inflated.contains(pt_a);
	}
1107051
private void triangulateFeatures(List<AssociatedTriple> inliers,
									 DMatrixRMaj P1, DMatrixRMaj P2, DMatrixRMaj P3) {
		List<DMatrixRMaj> cameraMatrices = new ArrayList<>();
		cameraMatrices.add(P1);
		cameraMatrices.add(P2);
		cameraMatrices.add(P3);

		// need elements to be non-empty so that it can use set().  probably over optimization
		List<Point2D_F64> triangObs = new ArrayList<>();
		triangObs.add(null);
		triangObs.add(null);
		triangObs.add(null);

		Point4D_F64 X = new Point4D_F64();
		for (int i = 0; i < inliers.size(); i++) {
			AssociatedTriple t = inliers.get(i);

			triangObs.set(0,t.p1);
			triangObs.set(1,t.p2);
			triangObs.set(2,t.p3);

			// triangulation can fail if all 3 views have the same pixel value. This has been observed in
			// simulated 3D scenes
			if( triangulator.triangulate(triangObs,cameraMatrices,X)) {
				structure.points[i].set(X.x,X.y,X.z,X.w);
			} else {
				throw new RuntimeException("Failed to triangulate a point in the inlier set?! Handle if this is common");
			}
		}
	}
1113522
protected List<Reference> mergeReferences(
			List<? extends Reference> references1,
			List<? extends Reference> references2) {
		List<Reference> result = new ArrayList<>();
		for (Reference reference : references1) {
			addBestReferenceToList(reference, result);
		}
		for (Reference reference : references2) {
			addBestReferenceToList(reference, result);
		}
		return result;
	}
505486
public static <T1, T2> void forEachInBoth(List<T1> list1, List<T2> list2, Procedure2<? super T1, ? super T2> procedure)
    {
        if (list1 != null && list2 != null)
        {
            int size1 = list1.size();
            int size2 = list2.size();
            if (size1 == size2)
            {
                for (int i = 0; i < size1; i++)
                {
                    procedure.value(list1.get(i), list2.get(i));
                }
            }
            else
            {
                throw new IllegalArgumentException("Attempt to call forEachInBoth with two Lists of different sizes :"
                        + size1
                        + ':'
                        + size2);
            }
        }
    }
458672
def _orbList(obj1, obj2, aspList):
    
    sep = angle.closestdistance(obj1.lon, obj2.lon)
    absSep = abs(sep)
    return [
        {
            'type': asp,
            'orb': abs(absSep - asp),
            'separation': sep,
        } for asp in aspList
    ]
863851
private void updateReferencePoint(List<? extends Solution<?>> solutionList) {
    double[] maxObjectives = new double[numberOfObjectives];
    for (int i = 0; i < numberOfObjectives; i++) {
      maxObjectives[i] = 0;
    }

    for (int i = 0; i < solutionList.size(); i++) {
      for (int j = 0; j < numberOfObjectives; j++) {
        if (maxObjectives[j] < solutionList.get(i).getObjective(j)) {
          maxObjectives[j] = solutionList.get(i).getObjective(j) ;
        }
      }
    }

    if (referencePoint == null) {
      referencePoint = new ArrayPoint(numberOfObjectives) ;
      for (int i = 0; i < numberOfObjectives ; i++) {
        referencePoint.setValue(i, Double.MAX_VALUE);
      }
    }

    for (int i = 0; i < referencePoint.getDimension(); i++) {
      referencePoint.setValue(i, maxObjectives[i] + offset);
    }
  }
1256962
function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {
		return	this._checkCounterclockwise(p, p2, p3) !==
				this._checkCounterclockwise(p1, p2, p3) &&
				this._checkCounterclockwise(p, p1, p2) !==
				this._checkCounterclockwise(p, p1, p3);
	}
1261755
private boolean refineWithBundleAdjustment(SceneObservations observations) {
		if( scaleSBA ) {
			scaler.applyScale(structure,observations);
		}

		sba.setVerbose(verbose,verboseLevel);
		sba.setParameters(structure,observations);
		sba.configure(converge.ftol,converge.gtol,converge.maxIterations);

		if( !sba.optimize(structure) ) {
			return false;
		}

		if( scaleSBA ) {
			// only undo scaling on camera matrices since observations are discarded
			for (int i = 0; i < structure.views.length; i++) {
				DMatrixRMaj P = structure.views[i].worldToView;
				scaler.pixelScaling.get(i).remove(P,P);
			}
			scaler.undoScale(structure,observations);
		}
		return true;
	}
358398
protected boolean validateBudgetForForm(ProposalDevelopmentDocumentContract pdDoc) throws S2SException {
        boolean valid = true;

        ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService.getBudget(pdDoc.getDevelopmentProposal());
        if(budget != null) {
            for (BudgetPeriodContract period : budget.getBudgetPeriods()) {
                List<String> participantSupportCode = new ArrayList<>();
                participantSupportCode.add(s2sBudgetCalculatorService.getParticipantSupportCategoryCode());
                List<? extends BudgetLineItemContract> participantSupportLineItems =
                        s2sBudgetCalculatorService.getMatchingLineItems(period.getBudgetLineItems(), participantSupportCode);
                int numberOfParticipants = period.getNumberOfParticipants() == null ? 0 : period.getNumberOfParticipants();
                if (!participantSupportLineItems.isEmpty() && numberOfParticipants == 0) {
                    AuditError auditError= s2SErrorHandlerService.getError(PARTICIPANT_COUNT_REQUIRED, getFormName());
                    AuditError error= new AuditError(auditError.getErrorKey(),
                            auditError.getMessageKey()+period.getBudgetPeriod(),auditError.getLink());
                    getAuditErrors().add(error);
                    valid = false;
                } else if (numberOfParticipants > 0 && participantSupportLineItems.isEmpty()) {
                    getAuditErrors().add(s2SErrorHandlerService.getError(PARTICIPANT_COSTS_REQUIRED, getFormName()));
                    valid = false;
                }
            }
        }
        return valid;
    }
1168044
public boolean process(CameraPinholeBrown intrinsic , Se3_F64 planeToCamera )
	{
		proj.setPlaneToCamera(planeToCamera,true);
		proj.setIntrinsic(intrinsic);

		// find a bounding rectangle on the ground which is visible to the camera and at a high enough resolution
		double x0 = Double.MAX_VALUE;
		double y0 = Double.MAX_VALUE;
		double x1 = -Double.MAX_VALUE;
		double y1 = -Double.MAX_VALUE;

		for( int y = 0; y < intrinsic.height; y++ ) {
			for( int x = 0; x < intrinsic.width; x++ ) {
				if( !checkValidPixel(x,y) )
					continue;

				if( plane0.x < x0 )
					x0 = plane0.x;
				if( plane0.x > x1 )
					x1 = plane0.x;
				if( plane0.y < y0 )
					y0 = plane0.y;
				if( plane0.y > y1 )
					y1 = plane0.y;
			}
		}

		if( x0 == Double.MAX_VALUE )
			return false;

		// compute parameters with the intent of maximizing viewing area
		double mapWidth = x1-x0;
		double mapHeight = y1-y0;
		overheadWidth = (int)Math.floor(mapWidth/cellSize);
		overheadHeight = (int)Math.floor(mapHeight* viewHeightFraction /cellSize);
		centerX = -x0;
		centerY = -(y0+mapHeight*(1- viewHeightFraction)/2.0);

		return true;
	}
1318958
@InternalFunction()
    public Boolean match(final List<ProxyField> list,final List<ProxyField> list2)
    {
    	if (list == null)
    	{
    		return Boolean.TRUE;
    	}
        for (ProxyField proxyField: list)
        {
            boolean found = false;
            for (ProxyField proxyField2: list2)
            {
                if (proxyField.getValue().equals(proxyField2.getValue()))
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                return Boolean.FALSE;
            }
        }
        return Boolean.TRUE;
    }
503385
private static void checkBehindCamera(SceneStructureMetric structure, SceneObservations observations, BundleAdjustment<SceneStructureMetric> bundleAdjustment) {

		int totalBehind = 0;
		Point3D_F64 X = new Point3D_F64();
		for (int i = 0; i < structure.points.length; i++) {
			structure.points[i].get(X);
			if( X.z < 0 )
				totalBehind++;
		}
		structure.views[1].worldToView.T.print();
		if( totalBehind > structure.points.length/2 ) {
			System.out.println("Flipping because it's reversed. score = "+bundleAdjustment.getFitScore());
			for (int i = 1; i < structure.views.length; i++) {
				Se3_F64 w2v = structure.views[i].worldToView;
				w2v.set(w2v.invert(null));
			}
			triangulatePoints(structure,observations);

			bundleAdjustment.setParameters(structure,observations);
			bundleAdjustment.optimize(structure);
			System.out.println("  after = "+bundleAdjustment.getFitScore());
		} else {
			System.out.println("Points not behind camera. "+totalBehind+" / "+structure.points.length);
		}
	}
892893
@Override
	public void set(Point3D p1, Point3D p2, Point3D p3) {
		set(p1.getX(), p1.getY(), p1.getZ(), p2.getX(), p2.getY(), p2.getZ(), p3.getX(), p3.getY(), p3.getZ());
	}