Exemplo n.º 1
0
 protected virtual IEnumerable <MarkupStyleDash> CalculateDashes(ILineTrajectory trajectory, LineBorders borders)
 {
     if (StyleHelper.CalculateSolidDash(borders, trajectory, 0f, Width, Color, out MarkupStyleDash dash))
     {
         yield return(dash);
     }
 }
Exemplo n.º 2
0
        public static IEnumerable <MarkupStyleDash> CalculateDashed(ILineTrajectory trajectory, float dashLength, float spaceLength, DashedGetter calculateDashes)
        {
            List <DashT> dashesT;

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

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

            default:
                yield break;
            }

            foreach (var dashT in dashesT)
            {
                foreach (var dash in calculateDashes(trajectory, dashT.Start, dashT.End))
                {
                    yield return(dash);
                }
            }
        }
Exemplo n.º 3
0
        public void Divide(out ILineTrajectory trajectory1, out ILineTrajectory trajectory2)
        {
            var middle = (Trajectory.a + Trajectory.b) / 2;

            trajectory1 = new StraightTrajectory(Trajectory.a, middle);
            trajectory2 = new StraightTrajectory(middle, Trajectory.b);
        }
Exemplo n.º 4
0
        private static IEnumerable <MarkupStyleDash> CalculateSolid(int depth, ILineTrajectory trajectory, float deltaAngle, Func <ILineTrajectory, IEnumerable <MarkupStyleDash> > calculateDashes)
        {
            var length = trajectory.Magnitude;

            var needDivide = (MinAngleDelta < deltaAngle && MinLength <= length) || MaxLength < length;

            if (depth < MaxDepth && (needDivide || depth == 0))
            {
                trajectory.Divide(out ILineTrajectory first, out ILineTrajectory second);
                var firstDeltaAngle  = first.DeltaAngle;
                var secondDeltaAngle = second.DeltaAngle;

                if (needDivide || MinAngleDelta < deltaAngle || MinAngleDelta < firstDeltaAngle + secondDeltaAngle)
                {
                    foreach (var dash in CalculateSolid(depth + 1, first, firstDeltaAngle, calculateDashes))
                    {
                        yield return(dash);
                    }

                    foreach (var dash in CalculateSolid(depth + 1, second, secondDeltaAngle, calculateDashes))
                    {
                        yield return(dash);
                    }

                    yield break;
                }
            }

            foreach (var dash in calculateDashes(trajectory))
            {
                yield return(dash);
            }
        }
Exemplo n.º 5
0
        public static List <MarkupIntersect> Calculate(ILineTrajectory trajectory1, ILineTrajectory trajectory2)
        {
            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>());
        }
Exemplo n.º 6
0
        public static IEnumerable <Result> CalculateSolid <Result>(int depth, ILineTrajectory trajectory, float deltaAngle, float minAngle, float minLength, float maxLength, Func <ILineTrajectory, IEnumerable <Result> > calculateDashes)
        {
            var length = trajectory.Magnitude;

            var needDivide = (minAngle < deltaAngle && minLength <= length) || maxLength < length;

            if (depth < MaxDepth && (needDivide || depth == 0))
            {
                trajectory.Divide(out ILineTrajectory first, out ILineTrajectory second);
                var firstDeltaAngle  = first.DeltaAngle;
                var secondDeltaAngle = second.DeltaAngle;

                if (needDivide || minAngle < deltaAngle || minAngle < firstDeltaAngle + secondDeltaAngle)
                {
                    foreach (var dash in CalculateSolid(depth + 1, first, firstDeltaAngle, minAngle, minLength, maxLength, calculateDashes))
                    {
                        yield return(dash);
                    }

                    foreach (var dash in CalculateSolid(depth + 1, second, secondDeltaAngle, minAngle, minLength, maxLength, calculateDashes))
                    {
                        yield return(dash);
                    }

                    yield break;
                }
            }

            foreach (var dash in calculateDashes(trajectory))
            {
                yield return(dash);
            }
        }
Exemplo n.º 7
0
        protected IEnumerable <MarkupStyleDash> CalculateCroswalkDash(ILineTrajectory trajectory, float startT, float endT, Vector3 direction, ILineTrajectory[] borders, float length, float width)
        {
            var position       = trajectory.Position((startT + endT) / 2);
            var dashTrajectory = new StraightTrajectory(position, position + direction, false);
            var intersects     = MarkupIntersect.Calculate(dashTrajectory, 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 MarkupStyleDash(startPosition, endPosition, direction, width, Color));
            }
        }
Exemplo n.º 8
0
        public override IEnumerable <MarkupStyleDash> Calculate(MarkupLine line, ILineTrajectory trajectory)
        {
            var borders = line.Borders;

            return(StyleHelper.CalculateSolid(trajectory, GetDashes));

            IEnumerable <MarkupStyleDash> GetDashes(ILineTrajectory trajectory) => CalculateDashes(trajectory, borders);
        }
Exemplo n.º 9
0
 public bool GetBorder(MarkupEnterPoint point, out ILineTrajectory line)
 {
     if (point.IsFirst && Markup.GetBordersLine(this, Prev, out line))
     {
         return(true);
     }
     else if (point.IsLast && Markup.GetBordersLine(this, Next, out line))
     {
         return(true);
     }
     else
     {
         line = null;
         return(false);
     }
 }
Exemplo n.º 10
0
 public override IEnumerable <MarkupStyleDash> Calculate(MarkupLine line, ILineTrajectory trajectory) => StyleHelper.CalculateSolid(trajectory, CalculateDashes);
Exemplo n.º 11
0
 public static List <MarkupIntersect> Calculate(ILineTrajectory trajectory, IEnumerable <ILineTrajectory> otherTrajectories, bool onlyIntersect = false)
 => otherTrajectories.SelectMany(t => Calculate(trajectory, t)).Where(i => !onlyIntersect || i.IsIntersect).ToList();
Exemplo n.º 12
0
 public static IEnumerable <MarkupStyleDash> CalculateSolid(ILineTrajectory trajectory, Func <ILineTrajectory, IEnumerable <MarkupStyleDash> > calculateDashes)
 => CalculateSolid(0, trajectory, trajectory.DeltaAngle, calculateDashes);
Exemplo n.º 13
0
 public static MarkupIntersect CalculateSingle(ILineTrajectory trajectory1, ILineTrajectory trajectory2) => Calculate(trajectory1, trajectory2).FirstOrDefault() ?? NotIntersect;
Exemplo n.º 14
0
 public abstract IEnumerable <MarkupStyleDash> Calculate(MarkupLine line, ILineTrajectory trajectory);
Exemplo n.º 15
0
 public override IEnumerable <MarkupStyleDash> Calculate(MarkupLine line, ILineTrajectory trajectory) => line is MarkupStopLine stopLine?Calculate(stopLine, trajectory) : new MarkupStyleDash[0];
Exemplo n.º 16
0
 public void Divide(out ILineTrajectory trajectory1, out ILineTrajectory trajectory2)
 {
     Trajectory.Divide(out Bezier3 bezier1, out Bezier3 bezier2);
     trajectory1 = new BezierTrajectory(bezier1);
     trajectory2 = new BezierTrajectory(bezier2);
 }
Exemplo n.º 17
0
 public TrajectoryBound(ILineTrajectory trajectory, float size)
 {
     Trajectory = trajectory;
     Size       = size;
     CalculateBounds();
 }
Exemplo n.º 18
0
 protected virtual IEnumerable <MarkupStyleDash> CalculateDashes(ILineTrajectory trajectory)
 {
     yield return(StyleHelper.CalculateSolidDash(trajectory, 0f, Width, Color));
 }
Exemplo n.º 19
0
 public static IEnumerable <Result> CalculateSolid <Result>(ILineTrajectory trajectory, Func <ILineTrajectory, IEnumerable <Result> > calculateDashes)
 => CalculateSolid(trajectory, MinAngleDelta, MinLength, MaxLength, calculateDashes);
Exemplo n.º 20
0
        public static void RenderTrajectory(RenderManager.CameraInfo cameraInfo, Color color, ILineTrajectory trajectory, float width = 0.2f, bool cut = false, bool alphaBlend = true)
        {
            switch (trajectory)
            {
            case BezierTrajectory bezierTrajectory:
                RenderBezier(cameraInfo, color, bezierTrajectory.Trajectory, width, cut, alphaBlend);
                break;

            case StraightTrajectory straightTrajectory:
                RenderBezier(cameraInfo, color, straightTrajectory.Trajectory.GetBezier(), width, cut, alphaBlend);
                break;
            }
        }
Exemplo n.º 21
0
        protected override IEnumerable <MarkupStyleDash> Calculate(MarkupStopLine stopLine, ILineTrajectory trajectory)
        {
            var offset = ((stopLine.Start.Direction + stopLine.End.Direction) / -2).normalized * (Width / 2);

            return(StyleHelper.CalculateSolid(trajectory, CalculateDashes));

            IEnumerable <MarkupStyleDash> CalculateDashes(ILineTrajectory dashTrajectory)
            {
                yield return(StyleHelper.CalculateSolidDash(dashTrajectory, offset, offset, Width, Color));
            }
        }
Exemplo n.º 22
0
 public static IEnumerable <Result> CalculateSolid <Result>(ILineTrajectory trajectory, float minAngle, float minLength, float maxLength, Func <ILineTrajectory, IEnumerable <Result> > calculateDashes)
 => CalculateSolid(0, trajectory, trajectory.DeltaAngle, minAngle, minLength, maxLength, calculateDashes);