Here are four points for you to find the minimum distance between one point and four points.
The feathed point of the Quadrilateral: the convex side is the intersection of two diagonal lines, and the concave side is a concave point.
PS:
The horse points of the triangle:
1. If the three inner angles of a triangle are less than 120 °, the three inner angles of the triangle are exactly the same as those of the third equi-fenma point, that is, the angle of the triangle on which the vertex is located is equal to 120 °. Therefore, the fenma point of a triangle is also called the Equi-angle center of a triangle.
2. If a triangle has an inner angle greater than or equal to 120 °, the vertices of the inner angle are the points of distance and minimum.
# Include <stdio. h> # include <string. h> # include <stdlib. h> # include <string> # include <queue> # include <map> # include <math. h >#include <algorithm> # include <iostream> using namespace STD; const int kind = 26; const int maxn = 250*1000; // Note RE, word Length * Number of words const int M = 5100000; struct point {Double X, Y ;}; // less than 0, note that the Polar Angle of vector p0p1 is greater than the Polar Angle of p0p2. Double multiply (point P1, point P2, point P0) {return (p1.x-0000x) * (p2.y-0000y) -(p2.x-Snapshot X )* (P1.y-p0.y);} double DIS (point P1, point P2) {return (SQRT (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y);} void graham_scan (point pointset [], point ch [], int N, Int & Len) {int I, j, k = 0, top = 2; point TMP; // find the lowest and leftmost point for (I = 1; I <n; I ++) if (pointset [I]. Y <pointset [K]. y) | (pointset [I]. y = pointset [K]. y) & (pointset [I]. x <pointset [K]. x) k = I; // specify this point as pointset [0] TMP = pointset [0]; pointset [0] = pointset [K]; pointset [k] = TMP; // sort by the polar angle from small to large and the distance is short for (I = 1; I <n-1; I ++) {k = I; for (j = I + 1; j <n; j ++) if (multiply (pointset [J], pointset [K], pointset [0])> 0) | (multiply (pointset [J], pointset [K], pointset [0]) = 0) & (DIS (pointset [0], pointset [J]) <DIS (pointset [0], pointset [k]) k = J; // K stores the vertex with the smallest polar angle, or the same TMP = pointset [I] closest to the origin; pointset [I] = pointset [k]; pointset [k] = TMP ;} // The third vertex first enters the stack ch [0] = pointset [0]; ch [1] = pointset [1]; c H [2] = pointset [2]; // judge the relationship with all other points for (I = 3; I <n; I ++) {// does not meet the left turn relationship. The top element of the stack goes out of the stack while (multiply (pointset [I], CH [Top], CH [Top-1])> = 0) top --; // The left-facing relationship between the current vertex and all vertices in the stack. ch [++ top] = pointset [I];} Len = Top + 1;} point intersection (point u1, point U2, point V1, point V2) {point ret = U1; Double T = (u1.x-v1.x) * (v1.y-v2.y)-(u1.y-v1.y) * (v1.x-v2.x )) /(u1.x-u2.x) * (v1.y-v2.y)-(u1.y-u2.y) * (v1.x-v2.x); ret. X + = (u2.x-u1.x) * t; ret. Y + = (U2.y-u1.y) * t; return ret;} point P [4], CH [4], point; int Len; int main () {int X1, Y1, x2, Y2, X3, Y3, X4, Y4; int X [4], Y [4]; while (scanf ("% lf", & P [0]. x, & P [0]. y) {int flag = 0; If (P [0]. x! =-1 | P [0]. y! =-1) Flag = 1; for (INT I = 1; I <4; I ++) {scanf ("% lf", & P [I]. x, & P [I]. y); If (P [I]. x! =-1 | P [I]. y! =-1) Flag = 1;} If (! Flag) break; double Minn = 10000000, ANS = 0.0; int K = 0; graham_scan (p, CH, 4, Len); For (INT I = 0; I <4; I ++) {ans = 0.0; For (Int J = 0; j <4; j ++) {ans + = DIS (P [I], P [J]);} If (ANS <Minn) Minn = ans;} Point = intersection (P [0], p [2], p [1], P [3]); // printf ("% lf \ n", point. x, point. y); ans = 0.0; For (INT I = 0; I <4; I ++) {ans + = DIS (P [I], point );} printf ("%. 4lf \ n ", min (Minn, ANS);} return 0 ;} /* 0 0 0 0 1 0 0 0 1 1 1 0 11 1 1 1 1 1 1 1 1 1 1-1-1-1-1-1-1-1-1 */