Last active
June 19, 2021 15:31
-
-
Save LucaDantas/812eed3349bf58423169eeaee4d01ee3 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 Pt { | |
int x, y; | |
Pt(int _x = 0, int _y = 0) : x(_x), y(_y) {} | |
Pt operator+(const Pt& o) { return Pt(x+o.x, y+o.y); } // soma de vetores | |
Pt operator-(const Pt& o) { return Pt(x-o.x, y-o.y); } // subtração de vetores | |
void operator+=(const Pt& o) { x += o.x, y += o.y; } // somar vetores com o operador += | |
void operator-=(const Pt& o) { x -= o.x, y -= o.y; } // subtrair vetores com o operador -= | |
long long operator*(const Pt& o) { return 1ll*x*o.x + 1ll*y*o.y; } // dot - produto escalar | |
long long operator/(const Pt& o) { return 1ll*x*o.y - 1ll*y*o.x; } // cross - produto vetorial | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment