Exemplo n.º 1
0
        private Point getClosestPointAbove(Point point, double offset, ShapeNode node, double[,] mesh)
        {
            //search nearest point above offset - circular iteration should work here
            var currentOffset = offset;
            var bestPoint     = new Point();

            while (true)
            {
                var maxDistance = double.NegativeInfinity;

                var spiralPoints = GetValidSpiralPoints(point, currentOffset);

                foreach (var spiralPoint in spiralPoints)
                {
                    var distance = GetBorderDistance(spiralPoint, mesh);
                    //var distance = getDistance(spiralPoint.X, spiralPoint.Y, node);
                    if (distance > maxDistance)
                    {
                        if (node.IntersectsWith(point, spiralPoint))
                        {
                            continue;
                        }

                        bestPoint   = spiralPoint;
                        maxDistance = distance;
                    }
                }

                if (maxDistance < 0)
                {
                    return(new Point(double.NaN, double.NaN));
                }

                if (maxDistance >= offset)
                {
                    break;
                }

                currentOffset += meshStep;
            }
            return(bestPoint);
        }