/// <summary> /// Returns the closest edge of this box to a point. /// </summary> /// <param name="point"></param> /// <returns>The closest edge of this box to a point.</returns> public virtual Segment2D ClosestEdgeTo(Vector2 point) { List <Vector2> perpendicularPoints = PerpendicularPointsTo(point); Vector2 closestPoint = Hedra.ClosestPoint(point, perpendicularPoints); int closestEdgeIndex = perpendicularPoints.IndexOf(closestPoint); return(Edges[closestEdgeIndex]); }
// Revisar - Closest Point debería ser el punto con menos distancia, no la intersección al centro. #region ClosestPointTo /// <summary> /// Returns the closest point of this polygon to a point. /// </summary> /// <param name="point"></param> /// <returns>The closest point of this polygon to a point.</returns> public virtual Vector2 ClosestPointTo(Vector2 point) { Segment2D cast = new Segment2D(Center, point); List <Vector2> intersections = IntersectionPoints(cast); if (intersections.Count == 0) // Point is inside polygon { Line2D line = new Line2D(Center, point); intersections = IntersectionPoints(line); return(Hedra.ClosestPoint(point, intersections)); } else if (intersections.Count == 1) { return(intersections[0]); } return(Hedra.ClosestPoint(point, intersections)); }
/// <summary> /// Returns the closest Vertex of this box to a point. /// </summary> /// <param name="point"></param> /// <returns>The closest Vertex of this box to a point.</returns> public virtual Vector2 ClosestVertexTo(Vector2 point) { return(Hedra.ClosestPoint(point, Vertices.ToList())); }
/// <summary> /// Returns the closest point of this box to a point. /// </summary> /// <param name="point"></param> /// <returns>The closest point of this box to a point.</returns> public virtual Vector2 ClosestPerpendicularPointTo(Vector2 point) { List <Vector2> perpendicularPoints = PerpendicularPointsTo(point); return(Hedra.ClosestPoint(point, perpendicularPoints)); }