Пример #1
0
        public static IEnumerable <PartT> CalculateDashesBezierT(BezierTrajectory bezierTrajectory, float dashLength, float spaceLength, uint iterations = 3)
        {
            var points  = GetDashesBezierPoints(bezierTrajectory);
            var indices = CalculateDashesBezierT(points, dashLength, spaceLength, iterations);
            var count   = points.Length - 1;

            for (var j = 1; j < indices.Count; j += 2)
            {
                var part = new PartT {
                    Start = 1f / count * indices[j - 1], End = 1f / count * indices[j]
                };
                yield return(part);
            }
        }
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!IsValid)
            {
                return(new MarkupStyleParts());
            }

            if (Invert)
            {
                trajectory = trajectory.Invert();
            }

            if (Shift != 0)
            {
                var startNormal = trajectory.StartDirection.Turn90(!Invert);
                var endNormal   = trajectory.EndDirection.Turn90(Invert);

                trajectory = new BezierTrajectory(trajectory.StartPosition + startNormal * Shift, trajectory.StartDirection, trajectory.EndPosition + endNormal * Shift, trajectory.EndDirection);
            }

            var length = trajectory.Length;

            if (OffsetBefore + OffsetAfter >= length)
            {
                return(new MarkupStyleParts());
            }

            var startT = OffsetBefore == 0f ? 0f : trajectory.Travel(OffsetBefore);
            var endT   = OffsetAfter == 0f ? 1f : 1f - trajectory.Invert().Travel(OffsetAfter);

            trajectory = trajectory.Cut(startT, endT);

            var count        = Mathf.CeilToInt(trajectory.Length / RepeatDistance);
            var trajectories = new ITrajectory[count];

            if (count == 1)
            {
                trajectories[0] = trajectory;
            }
            else
            {
                for (int i = 0; i < count; i += 1)
                {
                    trajectories[i] = trajectory.Cut(1f / count * i, 1f / count * (i + 1));
                }
            }

            return(new MarkupStyleNetwork(Prefab, trajectories, Prefab.Value.m_halfWidth * 2f, Prefab.Value.m_segmentLength, Scale, Elevation));
        }
Пример #3
0
        private void UpdateСontour()
        {
            BetweenEnters.Clear();

            for (var i = 0; i < EntersList.Count; i += 1)
            {
                var j    = i.NextIndex(EntersList.Count);
                var prev = EntersList[i];
                var next = EntersList[j];

                var betweenBezier = new Bezier3()
                {
                    a = prev.LastPointSide,
                    d = next.FirstPointSide
                };
                NetSegment.CalculateMiddlePoints(betweenBezier.a, prev.NormalDir, betweenBezier.d, next.NormalDir, true, true, out betweenBezier.b, out betweenBezier.c);

                BetweenEnters[i, j] = new BezierTrajectory(betweenBezier);
            }
        }
Пример #4
0
        private static List <PartT> CalculateDashesBezierT(BezierTrajectory bezierTrajectory, float dashLength, float spaceLength)
        {
            var partsT     = new List <PartT>();
            var trajectory = bezierTrajectory.Trajectory;
            var startSpace = spaceLength / 2;

            for (var i = 0; i < 3; i += 1)
            {
                partsT.Clear();
                var isPart = false;

                var prevT    = 0f;
                var currentT = 0f;
                var nextT    = trajectory.Travel(currentT, startSpace);

                while (nextT < 1)
                {
                    if (isPart)
                    {
                        partsT.Add(new PartT {
                            Start = currentT, End = nextT
                        });
                    }

                    isPart = !isPart;

                    prevT    = currentT;
                    currentT = nextT;
                    nextT    = trajectory.Travel(currentT, isPart ? dashLength : spaceLength);
                }

                float endSpace;
                if (isPart || ((trajectory.Position(1) - trajectory.Position(currentT)).magnitude is float tempLength && tempLength < spaceLength / 2))
                {
                    endSpace = (trajectory.Position(1) - trajectory.Position(prevT)).magnitude;
                }
Пример #5
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);
 }
Пример #6
0
        public static List <PartT> CalculateDashesBezierT(BezierTrajectory trajectory, float dashLength, float spaceLength, uint iterations = 3)
        {
            var points = new TrajectoryPoints(trajectory);

            return(CalculateDashesBezierT(points, dashLength, spaceLength, iterations));
        }