public override (Vector2 position, double time) GetSnappedPosition(Vector2 position)
        {
            Vector2 direction = position - CentrePosition;

            if (direction == Vector2.Zero)
            {
                direction = new Vector2(0.001f, 0.001f);
            }

            float distance = direction.Length;

            float radius      = DistanceSpacing;
            int   radialCount = Math.Max(1, (int)Math.Round(distance / radius));

            Vector2 normalisedDirection = direction * new Vector2(1f / distance);
            Vector2 snappedPosition     = CentrePosition + normalisedDirection * radialCount * radius;

            return(snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(StartTime, (snappedPosition - CentrePosition).Length));
        }
Example #2
0
        public override (Vector2 position, double time) GetSnappedPosition(Vector2 position)
        {
            if (MaxIntervals == 0)
            {
                return(StartPosition, StartTime);
            }

            Vector2 direction = position - StartPosition;

            if (direction == Vector2.Zero)
            {
                direction = new Vector2(0.001f, 0.001f);
            }

            float distance = direction.Length;

            float radius      = DistanceSpacing;
            int   radialCount = Math.Clamp((int)MathF.Round(distance / radius), 1, MaxIntervals);

            Vector2 normalisedDirection = direction * new Vector2(1f / distance);
            Vector2 snappedPosition     = StartPosition + normalisedDirection * radialCount * radius;

            return(snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(ReferenceObject, (snappedPosition - StartPosition).Length));
        }