コード例 #1
0
        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);
        }
コード例 #2
0
 void Update()
 {
     if (Time.time - updateTime >= secondsPerIteration)
     {
         solver.stepSolver();
         updateTime += secondsPerIteration;
     }
 }
コード例 #3
0
 void Update()
 {
     if (Time.time - updateTime >= 1f)
     {
         solver.stepSolver();
         updateTime += 1f;
     }
 }
コード例 #4
0
 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();
         }
     }
 }
コード例 #5
0
    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();
 }