12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include <iostream>
- #include "cLine.h"
- #include "point.h"
- using std::cout;
- using std::endl;
- //==========================
- cLine::cLine () : m_K (0), m_B (0) {}
- //==========================
- cLine::cLine (cPoint point1_, cPoint point2_) {
- cout << "Надо переопределить опертатор = для класса точка \n";
- m_point1.set_XYZ (point1_.get_X (), point1_.get_Y (), point1_.get_Z ());
- m_point2.set_XYZ (point2_.get_X (), point2_.get_Y (), point2_.get_Z ());
- // m_point1.show ();
- // cout << "poin1 \n"; m_point1.show ();
- // cout << "poin2 \n"; m_point2.show ();
- find_coff ();
- }
- //==========================
- cLine::cLine (double k_, double b_) {
- m_K = k_;
- m_B = b_;
- find_point ();
- }
- //==========================
- void cLine::find_coff () {
- m_K = (m_point1.get_Y () - m_point2.get_Y ()) / (m_point1.get_X () - m_point2.get_X ());
- m_B = m_point1.get_Y () - m_K*(m_point1.get_X ());
- cout << "m_K = " << m_K << endl;
- cout << "m_B = " << m_B << endl;
- }
- //==========================
- void cLine::find_point () {
- m_point1.set_Y (m_B);
- m_point1.set_X (-(m_B/m_K));
- cout << "что делать со второй точкой??? \n";
- }
- //==========================
- void cLine::show () {
- cout << "\t I am a line \n";
- cout << "m_K = " << m_K << endl;
- cout << "m_B = " << m_B << endl;
- cout << "\t My first point \n";
- // m_point1.show ();
- cout << "\n \t My second point \n";
- // m_point2.show ();
- }
- //==========================
- bool cLine::Ok () {
- cout << "Not now \n";
- return false;
- }
- //==========================
- bool cLine::parallel_me (cLine line1_) {
- if (m_K == line1_.get_K()) {
- cout << "\t PARALLEL \n";
- return true;
- }
- else {
- cout << "\t Not PARALLEL \n";
- return false;
- }
- }
|