Advertisement
_Muhammad

point3d

Feb 18th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1.  
  2. typedef long long ftype;
  3.  
  4. struct point3d {
  5.  
  6. ///We can declear as :
  7. /// point3d a (2, 3, 5);
  8.  
  9. ftype x, y, z;
  10. point3d() {}
  11.  
  12. point3d(ftype x, ftype y, ftype z): x(x), y(y), z(z) {}
  13. point3d& operator+=(const point3d &t) {
  14. x += t.x;
  15. y += t.y;
  16. z += t.z;
  17. return *this;
  18. }
  19.  
  20. point3d& operator-=(const point3d &t) {
  21. x -= t.x;
  22. y -= t.y;
  23. z -= t.z;
  24. return *this;
  25. }
  26.  
  27. point3d& operator*=(ftype t) {
  28. x *= t;
  29. y *= t;
  30. z *= t;
  31. return *this;
  32. }
  33.  
  34. point3d& operator/=(ftype t) {
  35. x /= t;
  36. y /= t;
  37. z /= t;
  38. return *this;
  39. }
  40.  
  41. point3d operator+(const point3d &t) const {
  42. return point3d(*this) += t;
  43. }
  44.  
  45. point3d operator-(const point3d &t) const {
  46. return point3d(*this) -= t;
  47. }
  48.  
  49. point3d operator*(ftype t) const {
  50. return point3d(*this) *= t;
  51. }
  52.  
  53. point3d operator/(ftype t) const {
  54. return point3d(*this) /= t;
  55. }
  56. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement