Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Line {
- public:
- Line(float _x1, float _y1, float _x2, float _y2) {
- x1 = _x1;
- x2 = _x2;
- y1 = _y1;
- y2 = _y2;
- slope = (_y2 - _y1) / (_x2 - _x1);
- length = sqrt(pow(_x2 - _x1, 2) + pow(_y2 - _y1, 2));
- }
- bool parallel(Line& line) {
- return line.slope == slope;
- }
- float slope, length, x1, x2, y1, y2;
- };
- int main() {
- Line one(0, 0, 2, 2);
- Line two(5, 5, 10, 10);
- cout << one.parallel(two);
- }
Advertisement
Add Comment
Please, Sign In to add comment