-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathECLineSegment.h
More file actions
72 lines (56 loc) · 1.56 KB
/
Copy pathECLineSegment.h
File metadata and controls
72 lines (56 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// ECLineSegment.h
//
//
// Created by Yufeng Wu on 1/22/21.
//
//
#ifndef ECLineSegment_h
#define ECLineSegment_h
#include <iostream>
// -----------------------------------------------------------------------------
// Point on 2D plane
class EC2DPoint
{
public:
EC2DPoint(double x, double y) : xCoord(x), yCoord(y) {};
double xCoord;
double yCoord;
EC2DPoint operator + (EC2DPoint const &p) const {
double x = xCoord + p.xCoord;
double y = yCoord + p.yCoord;
return EC2DPoint(x,y);
}
EC2DPoint operator - (EC2DPoint const &p) const {
double x = xCoord - p.xCoord;
double y = yCoord - p.yCoord;
return EC2DPoint(x,y);
}
bool operator == (EC2DPoint const &p) const {
return (xCoord == p.xCoord) && (yCoord == p.yCoord);
}
bool operator < (EC2DPoint const &p) const {
return true;
}
bool operator > (EC2DPoint const &p) const {
return false;
}
friend std::ostream& operator<<(std::ostream& os, const EC2DPoint &p);
private:
// your code goes here
};
// -----------------------------------------------------------------------------
// Line segment on 2D plane
class ECLineSegment
{
public:
ECLineSegment(const EC2DPoint &pStart, const EC2DPoint &pEnd) : pStart(pStart), pEnd(pEnd) {}
// Is this segment intersect with the other?
bool IsIntersect(const ECLineSegment &rhs) const;
// your code goes here
EC2DPoint pStart;
EC2DPoint pEnd;
private:
// your code goes here
};
#endif /* ECLineSegment_h */