Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Odcinek.h"
- #include <math.h>
- Odcinek::Odcinek()
- {
- p1 = new Punkt();
- p2 = new Punkt();
- };
- Odcinek::Odcinek(double x1, double y1, double x2, double y2)
- {
- p1 = new Punkt(x1, y1);
- p2 = new Punkt(x2, y2);
- };
- Odcinek::Odcinek(Punkt &punkt1, Punkt &punkt2)
- {
- p1 = &punkt1;
- p2 = &punkt2;
- };
- double Odcinek::dlugosc()
- {
- return sqrt((p1->x - p2->x)*(p1->x - p2->x) + (p1->y - p2->y)*(p1->y - p2->y)); // pierwiastek z (x1-x2)^2 + (y1-y2)^2
- };
- void Odcinek::rysuj()
- {
- cout << "Odcinek: " << p1->toString() << " - " << p2->toString() << endl;
- };
- void Odcinek::przesun(bool choice, double nowyx, double nowyy)
- {
- if (choice)
- {
- p1->x = nowyx;
- p1->y = nowyy;
- }
- else
- {
- p2->x = nowyx;
- p2->y = nowyy;
- }
- };
- void Odcinek::przesun_o(double deltax, double deltay)
- {
- p1->x += deltax;
- p1->y += deltay;
- p2->x += deltax;
- p2->y += deltay;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement