Created
April 26, 2014 14:41
-
-
Save vovanz/11321852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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