예제 #1
0
        public static ClosestEdgeSegmentResult FindClosestEdgeToSegment(Vector3 segmentStart,
                                                                        Vector3 segmentEnd,
                                                                        Edge[] edges)
        {
            var result = new ClosestEdgeSegmentResult()
            {
                Edge     = new Edge(),
                Distance = float.PositiveInfinity
            };

            for (int i = 0; i < edges.Length; ++i)
            {
                var edge = edges[i];
                if (!edge.Valid)
                {
                    continue;
                }

                float distance = ShortestDistanceSegmentSegment(segmentStart, segmentEnd, edge.Start, edge.End).Distance;
                if (distance < result.Distance)
                {
                    result.Edge     = edge;
                    result.Distance = distance;
                }
            }

            return(result);
        }
예제 #2
0
    public static ClosestEdgeSegmentResult FindClosestEdgeToSegment( Vector3 segmentStart, Vector3 segmentEnd, MeshUtils.Edge[] edges )
    {
      ClosestEdgeSegmentResult result = new ClosestEdgeSegmentResult( null, float.PositiveInfinity );
      for ( int i = 0; i < edges.Length; ++i ) {
        var edge = edges[ i ];
        if ( edge == null )
          continue;

        float distance = ShortestDistanceSegmentSegment( segmentStart, segmentEnd, edge.Start, edge.End ).Distance;
        if ( distance < result.Distance ) {
          result.Edge     = edge;
          result.Distance = distance;
        }
      }

      return result;
    }