Skip to content

Instantly share code, notes, and snippets.

@vovanz
Created April 26, 2014 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vovanz/11321852 to your computer and use it in GitHub Desktop.
Save vovanz/11321852 to your computer and use it in GitHub Desktop.
struct point {
double x, y;
point() {
x=0;
y=0;
}
point(double a, double b) {
x=a;
y=b;
}
point operator + (point a) {
return point(x+a.x, y+a.y);
}
point operator - (point a) {
return point(x-a.x, y-a.y);
}
double operator * (point a) {
return x*a.y - y*a.x;
}
double operator % (point a) {
return x*a.x + y*a.y;
}
double operator == (point a) {
return comp_double(x, a.x) && comp_double(y, a.y);
}
double operator != (point a) {
return !comp_double(x, a.x) || !comp_double(y, a.y);
}
double length() {
return sqrt(x*x+y*y);
}
point norm() {
return point(x/length(), y/length());
}
void scan() {
scanf("%lf%lf", &x, &y);
}
void print() {
printf("%lf %lf", x, y);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment