public void Solve() { startingDist = Vector3.Distance(raytracer.eyePerspective.transform.position, planePos); #if UNITY_EDITOR UnityEditor.Undo.RecordObject(newScreen, "Move Screen Position"); foreach (Testing.DenseOptimizer.TransformEntry trans in TransformsToOptimize) { UnityEditor.Undo.RecordObject(trans.TransformToOptimize, "Optimize Transform"); } #endif solver = new NelderMead(Testing.DenseOptimizer.calculateCoordsFromTransformEntries(ref TransformsToOptimize, rotationUnitRatio), costFunction, simplexSize); for (int i = 0; i < 100; i++) { solver.stepSolver(); } Testing.DenseOptimizer.setTransformsFromCoord(solver.simplexVertices[0].coordinates, ref TransformsToOptimize, rotationUnitRatio); newScreen.position = Vector3.ProjectOnPlane(newScreen.position - planePos, planeNormal) + planePos; newScreen.rotation = Quaternion.FromToRotation(newScreen.forward, planeNormal) * newScreen.rotation; //Debug.Log("First: " + solver.simplexVertices[0].cost + ", Last: " + solver.simplexVertices[solver.simplexVertices.Count - 1].cost); }
void Update() { if (Time.time - updateTime >= secondsPerIteration) { solver.stepSolver(); updateTime += secondsPerIteration; } }
void Update() { if (Time.time - updateTime >= 1f) { solver.stepSolver(); updateTime += 1f; } }
void Update() { if (PointCorrespondences.Count > 0 && Input.GetKey(KeyCode.Space)) { //This keeps the simplex from becoming degenerate solver.constructRightAngleSimplex(solver.simplexVertices[0].coordinates, 0.001f); for (int i = 0; i < 10; i++) { solver.stepSolver(); } } }
void Update() { if (reinitializeSolverEveryFrame) { //This keeps the simplex from becoming degenerate solver.constructRightAngleSimplex(solver.simplexVertices[0].coordinates, 1f); } else { //Only do this when the optimum is moving! solver.recalculateSimplexCosts(); } //Step the solver forward for (int i = 0; i < iterationsPerFrame; i++) { solver.stepSolver(); } }
void Update() { solver.stepSolver(); }