Well, because I am a computational geometry slag, so the title is to write a preliminary good ...
① Polygon Area poj3907
Find a point and cross-product the polygon's adjacent vertices. Add together to find the absolute value.
#include <iostream>#include<stdio.h>#include<stdlib.h>#include<algorithm>#include<string.h>#include<vector>#include<math.h>#include<limits>#include<Set>#include<map>using namespacestd;intN;Doublex[2333333],y[2333333];intMain () { while(SCANF ("%d",&N), N) { for(intI=0; i<n;i++) scanf ("%LF%LF", x+i,y+i); Doublemx=2000000000, my=2000000000; for(intI=0; i<n;i++) Mx=min (Mx,x[i]), my=min (my,y[i]); --MX; --my; Doubleans=0; for(intI=0; i<n;i++) { DoubleX1=X[I]-MX, y1=y[i]-my; Doublex2=x[(i+1)%n]-mx, y2=y[(i+1)%n]-my; Ans+=x1*y2-y1*x2; } ans/=2; if(ans<0) ans=-ans; printf ("%.0lf\n", ans); }}
② whether the point is inside the polygon zoj1081
Classic problem, as long as the point in one direction to do a ray (the level is prone to accidents), and then count the intersection of the polygon edge number.
It can be found that if the ray does not pass through the polygon vertices, it is only possible to judge the parity of the intersection.
Preliminary calculation of geometry