
Discussion An example of finding area is ConvexPolygon problem. Just do it. Here is the code:#include <vector>
#include <cmath>
using namespace std;
struct point {
double x,y;
point (double xx=0, double yy=0) {
x=xx;
y=yy;
}
};
double sq(const point &a, const point &b, const point &c) {
return (a.x*(b.yc.y)+b.x*(c.ya.y)+c.x*(a.yb.y))/2;
}
vector<point> a;
class ConvexPolygon {
public:
double findArea(vector<int> x, vector<int> y) {
int i;
int n=x.size();
for (i=0; i<n; ++i) a.push_back(point(x[i],y[i]));
double s=0;
for (i=1; i<=n2; ++i) s+=sq(a[0],a[i],a[i+1]);
s=fabs(s);
return s;
}
};
Another example of a very similar problem is Surveyor.
An example of checking is a point inside, outside or on a boundary of a polygon is PointInPolygon problem. Because all edges of the polygon here are parallel to coordinate axes, this problem can be solved in simpler way, but we forget about this favorable circumstance to demonstrate the general method. Also we demonstrate using of some geometrical routines. Take your attention that we don’t use a secure comparison of doubles in cases when we know in advance they differ more than our “epsilon”, our allowable absolute error. Here is the code:#include <vector>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
const double eps=1e6;
struct point {
double x,y;
point (double xx=0, double yy=0) {
x=xx;
y=yy;
}
point (const string &s) {
stringstream ss(s);
double x,y;
ss >> x >> y;
*this=point(x,y);
}
};
struct line {
double a,b,c;
};
bool eq(double a, double b) {
return fabs(ab)<=eps;
}
bool atline(const point &a, const line &l) {
return eq(l.a*a.x+l.b*a.y+l.c,0);
}
void point2toline(const point &p1, const point &p2, line &l) {
l.a=p1.yp2.y;
l.b=p2.xp1.x;
l.c=p1.x*p2.yp2.x*p1.y;
}
bool atline(const point &a, const point &p1, const point &p2) {
line l;
point2toline(p1,p2,l);
return atline(a,l);
}
bool lseq(double a, double b) {
return ba>=eps;
}
bool ls(double a, double b) {
return ba>eps;
}
bool lseq(const point &a, const point &b) {
if (!eq(a.x,b.x)) return a.x<b.x;
return lseq(a.y,b.y);
}
bool ls(const point &a, const point &b) {
if (!eq(a.x,b.x)) return a.x<b.x;
return ls(a.y,b.y);
}
bool inrectangle(const point &a, const point &lf, const point &rg) {
return lseq(lf,a) && lseq(a,rg)  lseq(rg,a) && lseq(a,lf);
}
bool atsegm(const point &a, const point &lf, const point &rg) {
return atline(a,lf,rg) && inrectangle(a,lf,rg);
}
bool eq(const point &a, const point &b) {
return eq(a.x,b.x) && eq(a.y,b.y);
}
bool crossline(const line &l1, const line &l2) {
return !eq(l1.a*l2.bl2.a*l1.b,0);
}
void line2topoint(const line &l1, const line &l2, point &p) {
double d=l1.a*l2.bl1.b*l2.a;
p.x=(l1.b*l2.cl2.b*l1.c)/d;
p.y=(l1.c*l2.al2.c*l1.a)/d;
}
point p;
vector<point> a;
int n;
class PointInPolygon {
public:
string testPoint (vector<string> vs, int tx, int ty) {
n=vs.size();
p=point(tx,ty);
int i;
for (i=0; i<n; ++i) a.push_back(point(vs[i]));
for (i=0; i<n; ++i) if (atsegm(p,a[i],a[(i+1)%n])) return "BOUNDARY";
line l;
l.a=0;
l.b=1;
l.c=p.y;
point pt;
int cnt=0;
line ln;
for (i=0; i<n; ++i) {
point2toline(a[i],a[(i+1)%n],ln);
if (crossline(l,ln)) {
line2topoint(l,ln,pt);
if (p.x<pt.x && inrectangle(pt,a[i],a[(i+1)%n])) {
if (!eq(pt,a[i]) && !eq(pt,a[(i+1)%n])) ++cnt; else {
if (eq(pt,a[i]) && ls(a[(i+1)%n].y,a[i].y) 
eq(pt,a[(i+1)%n]) && ls(a[i].y,a[(i+1)%n].y)) ++cnt;
}
}
}
}
if (cnt&1) return "INTERIOR"; else return "EXTERIOR";
}
};
Last to add. As with other geometrical problems, here a big part of implementation work is handling corner cases and, sometimes, caring about precision. 