コード例 #1
0
        public void markMark()
        {
            float elap = markstopwatch.ElapsedMilliseconds / 1000.0f;

            markElaped = elap;
            if (elap > errmarkIntervalSecs)
            {
                var maincam = Camera.main; // only works with one camera
                var campt   = maincam.transform.position;
                campt.y -= rman.home_height;
                //campt.y = 0;
                float pathlen   = 0;
                var   pathcampt = rman.pathctrl.FindClosestPointOnPath(campt, out pathlen);

                int i    = emlist.Count;
                var empt = new optimAnchorPoint("pt-" + i, campt, pathcampt, pathlen);
                emlist.AddLast(empt);
                nMarksInList += 1;
                RefreshGos();
                if (emlist.Count >= nErrmarkIntervalsInSet)
                {
                    markingState  = markingStateE.resting;
                    markstopwatch = null;
                }
                else
                {
                    markstopwatch.Reset();
                    markstopwatch.Start();
                }
            }
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: MikeWise2718/hummit
        public void test1case(float rotrad, float trnx, float trny, float trnz, bool noise = false, float noisefak = 1)
        {
            var ranman  = new Random(123);
            var oaplist = new LinkedList <optimAnchorPoint>();
            var o1      = new optimAnchorPoint("pt1", new Vk3(-1, 0, 0), new Vk3(-1, 0, 0));
            var o2      = new optimAnchorPoint("pt2", new Vk3(0, 0, 1), new Vk3(0, 0, 1));
            var o3      = new optimAnchorPoint("pt3", new Vk3(1, 0, 0), new Vk3(1, 0, 0));

            oaplist.AddLast(o1);
            oaplist.AddLast(o2);
            oaplist.AddLast(o3);

            float rx = 0, ry = 0, rz = 0;
            var   op = oaplist.First;

            while (op != null)
            {
                var t1 = op.Value.target;
                var t2 = Vk3.rotateY(rotrad, t1);
                var t3 = new Vk3(t2.x + trnx, t2.y + trny, t2.z + trnz);
                if (noise)
                {
                    rx = noisefak * (float)(2 * ranman.NextDouble() - 1) / 10;
                    ry = noisefak * (float)(2 * ranman.NextDouble() - 1) / 10;
                    rz = noisefak * (float)(2 * ranman.NextDouble() - 1) / 10;
                }
                var t4 = new Vk3(t3.x + rx, t3.y + ry, t3.z + rz);
                op.Value.target = t4;
                op = op.Next;
            }


            // Add them all to the opimizer
            var oapo = new oapOptimizer(optTypeSelectorE.rotYtransXYZ);

            op = oaplist.First;
            while (op != null)
            {
                oapo.addOap(op.Value);
                op = op.Next;
            }
            oapo.verbose = false;
            oapo.optimize();

            var scavek = oapo.scavek;
            var rotvek = oapo.rotvek;
            var twopi  = (float)(2 * Math.PI);

            if (rotvek.y < 0)
            {
                rotvek.y += twopi;
            }
            if (twopi < rotvek.y)
            {
                rotvek.y -= twopi;
            }
            if (rotvek.y < 0)
            {
                rotvek.y += twopi;               // can underflow twice
            }
            var trnvek = oapo.trnvek;
            var rotdif = Math.Abs(rotvek.y - rotrad);

            Assert.IsTrue(oapo.status == optStatusE.converged);
            if (!noise)
            {
                Assert.IsTrue(Math.Abs(rotvek.y - rotrad) < 0.0005); // 0.028 degrees
            }
            Assert.IsTrue(Math.Abs(trnvek.x - trnx) < (noisefak * 0.1));
            Assert.IsTrue(Math.Abs(trnvek.y - trny) < (noisefak * 0.1));
            Assert.IsTrue(Math.Abs(trnvek.z - trnz) < (noisefak * 0.1));
            Console.WriteLine("  rot:" + rotrad + "  rot.y:" + rotvek.y + "  diff:" + (rotrad - rotvek.y));
            Console.WriteLine("  trnx:" + trnx + "  trn.x:" + trnvek.x);
            Console.WriteLine("  trny:" + trny + "  trn.y:" + trnvek.y);
            Console.WriteLine("  trnz:" + trnz + "  trn.z:" + trnvek.z);
            Console.WriteLine(oapo.status + " s:" + scavek + " r:" + rotvek + " t:" + trnvek +
                              " iter:" + oapo.iter + "  fcalled:" + oapo.fcalled + " ferr:" + oapo.ferr);
        }