Commit a82f1f94 authored by Ulrich Kemloh's avatar Ulrich Kemloh

comment on the WhichSide function in class Line

parent 82357164
......@@ -340,18 +340,9 @@ bool Line::IsVertical() {
}
int Line::WichSide(const Point &pt) {
//special case for horizontal lines
if (IsVertical()) {
//left
if (pt._x < _point1._x)
return 0;
//right or colinear
if (pt._x >= _point1._x)
return 1;
}
return ((_point2._x - _point1._x) * (pt._y - _point1._y)
- (_point2._y - _point1._y) * (pt._x - _point1._x)) > 0;
if(IsLeft(pt)) return 0;
return 1;
}
......
......@@ -42,7 +42,8 @@ class OutputHandler;
extern OutputHandler* Log;
class Line {
class Line
{
private:
Point _point1;
Point _point2;
......@@ -198,14 +199,14 @@ public:
bool HasEndPoint(const Point& point) const;
/**
* return the same value if the checked points are all situated on the same side.
* @return 0 or 1 depending on which side of the line the point is located.
* Determine on which side the point is located on of the line directed from (_point1 to _point2).
* @return 0 (Left) or 1 (Right) depending on which side of the line the point is located.
* The return value is undefined if the points are colinear.
*/
int WichSide (const Point& pt);
/**
* @return true if the point is located in the left hand side of the line.
* For horizontal lines return true if the point is above the line.
* @return true if the point is located in the left hand side of the line directed from (_point1 to _point2).
*/
bool IsLeft (const Point& pt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment