cLine.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <iostream>
  2. #include "cLine.h"
  3. #include "point.h"
  4. using std::cout;
  5. using std::endl;
  6. //==========================
  7. cLine::cLine () : m_K (0), m_B (0) {}
  8. //==========================
  9. cLine::cLine (cPoint point1_, cPoint point2_) {
  10. cout << "Надо переопределить опертатор = для класса точка \n";
  11. m_point1.set_XYZ (point1_.get_X (), point1_.get_Y (), point1_.get_Z ());
  12. m_point2.set_XYZ (point2_.get_X (), point2_.get_Y (), point2_.get_Z ());
  13. // m_point1.show ();
  14. // cout << "poin1 \n"; m_point1.show ();
  15. // cout << "poin2 \n"; m_point2.show ();
  16. find_coff ();
  17. }
  18. //==========================
  19. cLine::cLine (double k_, double b_) {
  20. m_K = k_;
  21. m_B = b_;
  22. find_point ();
  23. }
  24. //==========================
  25. void cLine::find_coff () {
  26. m_K = (m_point1.get_Y () - m_point2.get_Y ()) / (m_point1.get_X () - m_point2.get_X ());
  27. m_B = m_point1.get_Y () - m_K*(m_point1.get_X ());
  28. cout << "m_K = " << m_K << endl;
  29. cout << "m_B = " << m_B << endl;
  30. }
  31. //==========================
  32. void cLine::find_point () {
  33. m_point1.set_Y (m_B);
  34. m_point1.set_X (-(m_B/m_K));
  35. cout << "что делать со второй точкой??? \n";
  36. }
  37. //==========================
  38. void cLine::show () {
  39. cout << "\t I am a line \n";
  40. cout << "m_K = " << m_K << endl;
  41. cout << "m_B = " << m_B << endl;
  42. cout << "\t My first point \n";
  43. // m_point1.show ();
  44. cout << "\n \t My second point \n";
  45. // m_point2.show ();
  46. }
  47. //==========================
  48. bool cLine::Ok () {
  49. cout << "Not now \n";
  50. return false;
  51. }
  52. //==========================
  53. bool cLine::parallel_me (cLine line1_) {
  54. if (m_K == line1_.get_K()) {
  55. cout << "\t PARALLEL \n";
  56. return true;
  57. }
  58. else {
  59. cout << "\t Not PARALLEL \n";
  60. return false;
  61. }
  62. }