コード例 #1
0
 protected virtual void HandleScreenEdgeReverseDirection(Sprite sprite, ITrajectory trajectory)
 {
     if (sprite.Bounds.Position.X < 0)
     {
         sprite.Bounds.Position.X += sprite.RendererData.StepX;
         trajectory.Direction      = Direction.Right;
         OnReverseDirection(sprite, trajectory);
     }
     else if (sprite.Bounds.Position.X + sprite.Bounds.Size.Width > GameArea.Width)
     {
         sprite.Bounds.Position.X -= sprite.RendererData.StepX;
         trajectory.Direction      = Direction.Left;
         OnReverseDirection(sprite, trajectory);
     }
     else if (sprite.Bounds.Position.Y < 0)
     {
         sprite.Bounds.Position.Y += sprite.RendererData.StepY;
         trajectory.Direction      = Direction.Down;
         OnReverseDirection(sprite, trajectory);
     }
     else if (sprite.Bounds.Position.Y + sprite.Bounds.Size.Height > GameArea.Height)
     {
         sprite.Bounds.Position.Y -= sprite.RendererData.StepY;
         trajectory.Direction      = Direction.Up;
         OnReverseDirection(sprite, trajectory);
     }
 }
コード例 #2
0
        private void Present(ITrajectoryBundle tb)
        {
            int i = 1;

            foreach (ITrajectory traj in tb.Trajectories)
            {
                this.BeginPresentation(_datadir, traj.Name + "-" + i + ".tra");
                Present(traj, i, tb.Trajectories.Count);
                this.EndPresentation();
                i++;
            }

            ITrajectory meanTraj   = tb.MeanTrajectory;
            ITrajectory stdTraj    = tb.StdTrajectory;
            ITrajectory centerTraj = tb.CentralTrajectory;
            ITrajectory centerDev  = tb.CentralDevTrajectory;

            this.BeginPresentation(_datadir, meanTraj.Name + ".tra");
            PresentMean(meanTraj, stdTraj);
            this.EndPresentation();

            this.BeginPresentation(_datadir, centerTraj.Name + TrajectoryBundleCollapser_CentralDTW.SUFFIX + ".tra");
            PresentCenter(centerTraj, centerDev);
            this.EndPresentation();

            this.BeginPresentation(_gpdir, tb.Name + ".traj.gp");
            CreateGnuplotScript(tb, meanTraj, centerTraj);
            this.EndPresentation();
        }
コード例 #3
0
        public ITrajectory eval(ITrajectoryBundle tb)
        {
            ITrajectory central = tb.CentralTrajectory;

            ITrajectory dev = new Trajectory(tb.Name + SUFFIX, tb.TemporalGranularityThreshold, 0.0, 0.0);

            foreach (double t in central.Times)
            {
                double max        = Double.NegativeInfinity;
                double centralval = central.eval(t);

                foreach (ITrajectory traj in tb.Trajectories)
                {
                    if (traj == central)
                    {
                        continue;
                    }
                    if (traj.Times.Count == 0)
                    {
                        continue;
                    }

                    double y    = traj.eval(t);
                    double diff = Math.Abs(y - centralval);
                    if (diff > max)
                    {
                        max = diff;
                    }
                }

                dev.add(t, max);
            }

            return(dev);
        }
コード例 #4
0
        private void PresentMean(ITrajectory mean, ITrajectory std)
        {
            string header = "# Trajectory " + mean.Name + "";

            this.AppendToPresentation(header);
            header = "# time mean std";
            this.AppendToPresentation(header);

            int    count = 0;
            double step  = (mean.MaximumTime - mean.MinimumTime) / STEPS;

            for (double x = mean.MinimumTime; x <= mean.MaximumTime; x += step)         /// NULL TRAJECTORY FIX
            {
                double y   = mean.eval(x);
                double bar = std.eval(x);
                string str = "" + x + "\t" + y + "\t" + bar;
                this.AppendToPresentation(str);

                if (step == 0.0)
                {
                    break;                            /// NULL TRAJECTORY FIX
                }
                count++;
                if (count >= STEPS)
                {
                    break;
                }
            }
        }
コード例 #5
0
        private void PresentCenter(ITrajectory center, ITrajectory dev)
        {
            string header = "# Trajectory " + center.Name + TrajectoryBundleCollapser_CentralDTW.SUFFIX;

            this.AppendToPresentation(header);
            header = "# time center dev";
            this.AppendToPresentation(header);

            int    count = 0;
            double step  = (center.MaximumTime - center.MinimumTime) / STEPS;

            for (double x = center.MinimumTime; x <= center.MaximumTime; x += step)         /// NULL TRAJECTORY FIX
            {
                double ctr   = center.eval(x);
                double delta = dev.eval(x);
                string str   = "" + x + "\t" + ctr + "\t" + delta;
                this.AppendToPresentation(str);

                if (step == 0.0)
                {
                    break;                            /// NULL TRAJECTORY FIX
                }
                count++;
                if (count >= STEPS)
                {
                    break;
                }
            }
        }
コード例 #6
0
        private void Present(ITrajectory traj, int i, int n)
        {
            string header = "# Number " + i + " of " + n + "";

            this.AppendToPresentation(header);
            Present(traj);
        }
コード例 #7
0
        private void Present(ITrajectory traj)
        {
            string header = "# Trajectory " + traj.Name + "";

            this.AppendToPresentation(header);
            header = "# time value";
            this.AppendToPresentation(header);

            int    count = 0;
            double step  = (traj.MaximumTime - traj.MinimumTime) / STEPS;

            for (double x = traj.MinimumTime; x <= traj.MaximumTime; x += step)         /// NULL TRAJECTORY FIX
            {
                double y   = traj.eval(x);
                string str = "" + x + "\t" + y + "";
                this.AppendToPresentation(str);

                if (step == 0.0)
                {
                    break;                            /// NULL TRAJECTORY FIX
                }
                count++;
                if (count >= STEPS)
                {
                    break;
                }
            }
        }
コード例 #8
0
ファイル: StyleHelper.cs プロジェクト: MacSergey/NodeMarkup
        public static List <ITrajectory> CalculateSolid(ITrajectory trajectory, float minAngle, float minLength, float maxLength)
        {
            var result = new List <ITrajectory>();

            CalculateSolid(0, trajectory, trajectory.DeltaAngle, minAngle, minLength, maxLength, t => result.Add(t));
            return(result);
        }
コード例 #9
0
ファイル: StyleHelper.cs プロジェクト: MacSergey/NodeMarkup
        public static List <Result> CalculateSolid <Result>(ITrajectory trajectory, float minAngle, float minLength, float maxLength, Func <ITrajectory, Result> calculateParts)
        {
            var result = new List <Result>();

            CalculateSolid(0, trajectory, trajectory.DeltaAngle, minAngle, minLength, maxLength, t => result.Add(calculateParts(t)));
            return(result);
        }
コード例 #10
0
        public override void SetUpReference()
        {
            IPlayerInputManager inputManager = inputManagerAdaptor.GetInputManager();

            thisShootingManager.SetInputManager(inputManager);

            ILaunchPoint launchPoint = launchPointAdaptor.GetLaunchPoint();

            thisShootingManager.SetLaunchPoint(launchPoint);

            ITrajectory trajectory = trajectoryAdaptor.GetTrajectory();

            thisShootingManager.SetTrajectory(trajectory);

            ILandedArrowReserve landedArrowReserve = landedArrowReserveAdaptor.GetLandedArrowReserve();

            thisShootingManager.SetLandedArrowReserve(landedArrowReserve);

            IArrowReserve arrowReserve = arrowReserveAdaptor.GetArrowReserve();

            thisShootingManager.SetArrowReserve(arrowReserve);

            // IArrowTrailReserve arrowTrailReserve = arrowTrailReserveAdaptor.GetArrowTrailReserve();
            // thisShootingManager.SetArrowTrailReserve(arrowTrailReserve);

            ICriticalFlash flash = criticalFlashAdaptor.GetCriticalFlash();

            thisShootingManager.SetCriticalFlash(flash);

            IShootingDataManager shootingDataManager = shootingDataManagerAdaptor.GetShootingDataManager();

            thisShootingManager.SetShootingDataManager(shootingDataManager);
        }
コード例 #11
0
ファイル: StyleHelper.cs プロジェクト: MacSergey/NodeMarkup
        public static MarkupStylePart CalculateSolidPart(ITrajectory trajectory, Vector3 startOffset, Vector3 endOffset, float width, Color32 color)
        {
            var startPosition = trajectory.StartPosition + startOffset;
            var endPosition   = trajectory.EndPosition + endOffset;

            return(new MarkupStylePart(startPosition, endPosition, endPosition - startPosition, width, color));
        }
コード例 #12
0
        public void RandomWalkTest()
        {
            Console.WriteLine("RandomWalkTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Info);
            double y = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);

            for (double x = 0.0; x < WINDOW; x += 1.0)
            {
                double STEP;
                if (SingletonRandomGenerator.Instance.NextDouble() <= 0.5)
                {
                    STEP = 0.1;
                }
                else
                {
                    STEP = -0.1;
                }
                y = y + STEP;
                // traj.add(x,y);
                traj.add(x, STEP);
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of RandomWalk\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
コード例 #13
0
        public void LinearHurstTest()
        {
            Console.WriteLine("LinearHurstTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Debug);
            double m = 0.1;
            double b = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);
            double      INC  = 1.0;

            for (double x = 0.0; x < WINDOW; x += INC)
            {
                double NOISE_SCALE = 0.0001;
                double noise       = 2.0 * NOISE_SCALE * SingletonRandomGenerator.Instance.NextDouble() - NOISE_SCALE;

                double y = m * INC + noise;

                traj.add(x, y);
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of y = " + m + " x + " + b + "\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
コード例 #14
0
        public void RandomBinaryTest()
        {
            Console.WriteLine("RandomBinaryTest");
            LoggerInitialization.SetThreshold(typeof(hurst_tests), LogLevel.Debug);
            LoggerInitialization.SetThreshold(typeof(TrajectoryTransformer_Hurst), LogLevel.Debug);
            double y = 0.0;

            ITrajectory traj = new Trajectory("data", 1.0, 0.0, 0.0);

            bool pos = true;

            for (double x = 0.0; x < WINDOW; x += 1.0)
            {
                if (pos)
                {
                    y = 1.0;
                    traj.add(x, y);
                    pos = false;
                }
                else
                {
                    y = -1.0;
                    traj.add(x, y);
                    pos = true;
                }
            }

            ITrajectoryTransformer tx        = new TrajectoryTransformer_Hurst(WINDOW, 1.0);
            ITrajectory            trajHurst = tx.eval(traj);

            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "Hurst of Random Alternating\n");
            SingletonLogger.Instance().DebugLog(typeof(hurst_tests), "" + trajHurst.ToStringLong());
        }
コード例 #15
0
 protected virtual IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory trajectory, float startT, float endT, LineBorders borders)
 {
     if (StyleHelper.CalculateDashedParts(borders, trajectory, startT, endT, DashLength, 0, Width, Color, out MarkupStylePart dash))
     {
         yield return(dash);
     }
 }
コード例 #16
0
ファイル: NodeMarkup.cs プロジェクト: Vince0789/NodeMarkup
        public bool GetBordersLine(Enter first, Enter second, out ITrajectory line)
        {
            var i = EntersList.IndexOf(first);
            var j = EntersList.IndexOf(second);

            return(BetweenEnters.TryGetValue(i, j, out line));
        }
コード例 #17
0
ファイル: Intersects.cs プロジェクト: Vince0789/NodeMarkup
        public static List <MarkupIntersect> Calculate(ITrajectory trajectory1, ITrajectory trajectory2)
        {
            if (trajectory1 != null && trajectory2 != null)
            {
                if (trajectory1.TrajectoryType == TrajectoryType.Bezier)
                {
                    if (trajectory2.TrajectoryType == TrajectoryType.Bezier)
                    {
                        return(Calculate(trajectory1 as BezierTrajectory, trajectory2 as BezierTrajectory));
                    }
                    else if (trajectory2.TrajectoryType == TrajectoryType.Line)
                    {
                        return(Calculate(trajectory1 as BezierTrajectory, trajectory2 as StraightTrajectory));
                    }
                }
                else if (trajectory1.TrajectoryType == TrajectoryType.Line)
                {
                    if (trajectory2.TrajectoryType == TrajectoryType.Bezier)
                    {
                        return(Calculate(trajectory1 as StraightTrajectory, trajectory2 as BezierTrajectory));
                    }
                    else if (trajectory2.TrajectoryType == TrajectoryType.Line)
                    {
                        return(Calculate(trajectory1 as StraightTrajectory, trajectory2 as StraightTrajectory));
                    }
                }
            }

            return(new List <MarkupIntersect>());
        }
コード例 #18
0
        public double eval(ITrajectory traj1, ITrajectory traj2, double t)
        {
            if ((_traj1 != traj1) || (_traj2 != traj2))
            {
                double dt1 = (traj1.MaximumTime - traj1.MinimumTime) / (double)TIME_GRID;
                double dt2 = (traj2.MaximumTime - traj2.MinimumTime) / (double)TIME_GRID;
                _dt = Math.Min(dt1, dt2);
                int w = (int)(WARP_TIME_SECONDS / _dt);
                computeDTWArray(traj1, traj2, TIME_GRID, w);
            }
            int index1 = (int)(t / _dt);
            int i      = TIME_GRID - 1;
            int j      = TIME_GRID - 1;

            while (i > index1)
            {
                if (_move[i, j] == 'x')
                {
                    i = i - 1;
                }
                if (_move[i, j] == 'y')
                {
                    j = j - 1;
                }
                if (_move[i, j] == 'b')
                {
                    i = i - 1; j = j - 1;
                }
            }
            return(traj1.eval(_dt * (double)i) - traj2.eval(_dt * (double)j));
        }
コード例 #19
0
ファイル: Trajectory.cs プロジェクト: Vince0789/NodeMarkup
        public void Divide(out ITrajectory trajectory1, out ITrajectory trajectory2)
        {
            var middle = (Trajectory.a + Trajectory.b) / 2;

            trajectory1 = new StraightTrajectory(Trajectory.a, middle);
            trajectory2 = new StraightTrajectory(middle, Trajectory.b);
        }
コード例 #20
0
        protected IEnumerable <MarkupStylePart> CalculateCroswalkPart(ITrajectory trajectory, float startT, float endT, Vector3 direction, ITrajectory[] borders, float length, float width, Color32 color)
        {
            var position       = trajectory.Position((startT + endT) / 2);
            var partTrajectory = new StraightTrajectory(position, position + direction, false);
            var intersects     = Intersection.Calculate(partTrajectory, borders, true);

            intersects = intersects.OrderBy(i => i.FirstT).ToList();

            var halfLength = length / 2;
            var halfWidth  = width / 2;

            for (var i = 1; i < intersects.Count; i += 2)
            {
                var startOffset = GetOffset(intersects[i - 1], halfWidth);
                var endOffset   = GetOffset(intersects[i], halfWidth);

                var start = Mathf.Clamp(intersects[i - 1].FirstT + startOffset, -halfLength, halfLength);
                var end   = Mathf.Clamp(intersects[i].FirstT - endOffset, -halfLength, halfLength);

                var delta = end - start;
                if (delta < 0.9 * length && delta < 0.67 * width)
                {
                    continue;
                }

                var startPosition = position + direction * start;
                var endPosition   = position + direction * end;

                yield return(new MarkupStylePart(startPosition, endPosition, direction, width, color));
            }
        }
コード例 #21
0
ファイル: TrajectoryLib.cs プロジェクト: isncg/stglab
        public ITrajectory Get(TrajectoryType trajectoryType)
        {
            ITrajectory trajectory = null;

            traj.TryGetValue((int)trajectoryType, out trajectory);
            return(trajectory);
        }
コード例 #22
0
        public ITrajectory eval(ITrajectory traj1, ITrajectory traj2)
        {
            if ((_traj1 != traj1) || (_traj2 != traj2))
            {
                double dt1 = (traj1.MaximumTime - traj1.MinimumTime) / (double)TIME_GRID;
                double dt2 = (traj2.MaximumTime - traj2.MinimumTime) / (double)TIME_GRID;
                _dt = Math.Min(dt1, dt2);
                int w = (int)(WARP_TIME_SECONDS / _dt);
                computeDTWArray(traj1, traj2, TIME_GRID, w);
            }
            Trajectory traj = new Trajectory(traj1.Name + "-" + traj2.Name, 0.0, 0.0, 0.0);
            int        i    = TIME_GRID - 1;
            int        j    = TIME_GRID - 1;

            while ((i != 0) || (j != 0))
            {
                traj.add(_dt * (double)i, traj1.eval(_dt * (double)i) - traj2.eval(_dt * (double)j));
                if (_move[i, j] == 'x')
                {
                    i = i - 1;
                }
                if (_move[i, j] == 'y')
                {
                    j = j - 1;
                }
                if (_move[i, j] == 'b')
                {
                    i = i - 1; j = j - 1;
                }
            }
            return(traj);
        }
コード例 #23
0
ファイル: StyleHelper.cs プロジェクト: Vince0789/NodeMarkup
        public static IEnumerable <MarkupStylePart> CalculateDashed(ITrajectory trajectory, float dashLength, float spaceLength, DashedGetter calculateDashes)
        {
            List <PartT> partsT;

            switch (trajectory)
            {
            case BezierTrajectory bezierTrajectory:
                partsT = CalculateDashesBezierT(bezierTrajectory, dashLength, spaceLength);
                break;

            case StraightTrajectory straightTrajectory:
                partsT = CalculateDashesStraightT(straightTrajectory, dashLength, spaceLength);
                break;

            default:
                yield break;
            }

            foreach (var partT in partsT)
            {
                foreach (var part in calculateDashes(trajectory, partT.Start, partT.End))
                {
                    yield return(part);
                }
            }
        }
コード例 #24
0
        protected override IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory trajectory, LineBorders borders)
        {
            var firstOffset = Alignment.Value switch
            {
                Manager.Alignment.Left => 2 * Offset,
                Manager.Alignment.Centre => Offset,
                Manager.Alignment.Right => 0,
                _ => 0,
            };
            var secondOffset = Alignment.Value switch
            {
                Manager.Alignment.Left => 0,
                Manager.Alignment.Centre => - Offset,
                Manager.Alignment.Right => - 2 * Offset,
                _ => 0,
            };

            if (StyleHelper.CalculateSolidPart(borders, trajectory, firstOffset, Width, Color, out MarkupStylePart firstDash))
            {
                yield return(firstDash);
            }

            if (StyleHelper.CalculateSolidPart(borders, trajectory, secondOffset, Width, Color, out MarkupStylePart secondDash))
            {
                yield return(secondDash);
            }
        }
コード例 #25
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var solidOffset  = CenterSolid ? 0 : Invert ? Offset : -Offset;
            var dashedOffset = (Invert ? -Offset : Offset) * (CenterSolid ? 2 : 1);
            var borders      = line.Borders;

            var dashes = new List <MarkupStylePart>();

            dashes.AddRange(StyleHelper.CalculateSolid(trajectory, lod, CalculateSolidDash));
            if (CheckDashedLod(lod, Width, DashLength))
            {
                dashes.AddRange(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashedDash));
            }

            return(new MarkupStyleParts(dashes));

            IEnumerable <MarkupStylePart> CalculateSolidDash(ITrajectory lineTrajectory)
            {
                if (StyleHelper.CalculateSolidPart(borders, lineTrajectory, solidOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }

            IEnumerable <MarkupStylePart> CalculateDashedDash(ITrajectory lineTrajectory, float startT, float endT)
            {
                if (StyleHelper.CalculateDashedParts(borders, lineTrajectory, startT, endT, DashLength, dashedOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }
        }
コード例 #26
0
 protected virtual IEnumerable <MarkupStylePart> CalculateDashes(ITrajectory trajectory, LineBorders borders)
 {
     if (StyleHelper.CalculateSolidPart(borders, trajectory, 0f, Width, Color, out MarkupStylePart dash))
     {
         yield return(dash);
     }
 }
コード例 #27
0
ファイル: Render.cs プロジェクト: MacSergey/NodeMarkup
        public MarkupStyleLineMesh(ITrajectory trajectory, float width, float elevation, MaterialType materialType) : base(HalfWidth * 2f, HalfLength * 2f)
        {
            var position = (trajectory.StartPosition + trajectory.EndPosition) / 2;

            CalculateMatrix(trajectory, width, position, out Matrix4x4 left, out Matrix4x4 right);
            position += Vector3.up * (elevation - Height);
            Init(position, left, right, materialType);
        }
コード例 #28
0
 private void computeDTWArray(ITrajectory traj1, ITrajectory traj2, int n, int w)
 {
     double [] s = TrajectoryToArray(traj1, n);
     double [] t = TrajectoryToArray(traj2, n);
     DTWDistance(s, t, w);
     _traj1 = traj1;
     _traj2 = traj2;
 }
コード例 #29
0
        protected override IStyleData Calculate(MarkupStopLine stopLine, ITrajectory trajectory, MarkupLOD lod)
        {
            var offset = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized * (Width / 2);

            return(new MarkupStyleParts(StyleHelper.CalculateSolid(trajectory, lod, CalculateDashes)));

            MarkupStylePart CalculateDashes(ITrajectory dashTrajectory) => StyleHelper.CalculateSolidPart(dashTrajectory, offset, offset, Width, Color);
        }
コード例 #30
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var borders = line.Borders;

            return(new MarkupStyleParts(StyleHelper.CalculateSolid(trajectory, lod, GetDashes)));

            IEnumerable <MarkupStylePart> GetDashes(ITrajectory trajectory) => CalculateDashes(trajectory, borders);
        }