Advertisement
shchuko

Vector3D in Geometry3D

Mar 18th, 2020
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. class IVector3D {
  2. public:
  3.     double getX() = 0;
  4.     double getY() = 0;
  5.     double getZ() = 0;
  6.     double getLen() = 0;
  7.     double isCollinear() = 0;
  8.     double getAngleCos() = 0;
  9. }
  10.  
  11. // =>>>>>>>>>> Other file, other class CFixedVector3D
  12.  
  13. class CVector3D : public IVector3D {
  14.     // ........
  15. }
  16.  
  17.  
  18. // =>>>>>>>>>> Other file, other class
  19.  
  20.  
  21. // The idea: if points're changed, vector changes too
  22. class CLinkedVector3D : public IVector3D {
  23. private:
  24.     // References here!
  25.     CPoint3D &point_begin;
  26.     CPoint3D &point_end;
  27.  
  28. public:
  29.     CVector3DPointsLinked() = default;
  30.  
  31.     CVector3DPointsLinked(CPoint3D& point_begin, CPoint3D& point_end) {
  32.         this->point_begin = point_begin;
  33.         this->point_end = point_end;
  34.     }
  35.  
  36.     // Other constructors
  37.     // ...
  38.    
  39.  
  40.     double getX() {
  41.         return point_end.getX() - point_begin.getX();
  42.     }
  43.  
  44.     // Other methods equal to CVector3D
  45.     // ...
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement