Advertisement
nq1s788

Untitled

Aug 15th, 2024
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. struct vect {
  2.     ld x, y;
  3.     vect(): x(0), y(0) {}
  4.     vect(ld x, ld y): x(x), y(y) {}
  5.     vect(vect a, vect b): x(b.x - a.x), y(b.y - a.y) {}
  6. };
  7.  
  8. vect operator+(vect a, vect b) {
  9.     return vect(a.x + b.x, a.y + b.y);
  10. }
  11.  
  12. ld operator*(vect a, vect b) {
  13.     return a.x * b.x + a.y * b.y;
  14. }
  15.  
  16. vect operator*(vect a, ld k) {
  17.     return vect(a.x * k, a.y * k);
  18. }
  19.  
  20. ld operator^(vect a, vect b) {
  21.     return a.x * b.y - b.x * a.y;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement