SegmentIntersection Struct Reference

## Public Member Functions

bool | intersect (Point first_point, Point second_point, Point third_point, Point forth_point)
int | direction (Point first_point, Point second_point, Point third_point)
bool | on_segment (Point first_point, Point second_point, Point third_point)

## Detailed Description

intersect returns true if segments of two line intersects and false if they do not. It calls the subroutines direction which computes the orientation.

## Member Function Documentation

## direction()

int SegmentIntersection::direction | ( | Point | first_point,
|  | Point | second_point,
|  | Point | third_point
| ) |  |

inline

We will find direction of line here respect to @first_point. Here @second_point and @third_point is first and second points of the line respectively. we want a method to determine which way a given angle these three points turns. If returned number is negative, then the angle is counter-clockwise. That means the line is going to right to left. We will fount angle as clockwise if the method returns positive number.

{
return ((third_point.x - first_point.x) *
(second_point.y - first_point.y)) -
((second_point.x - first_point.x) *
(third_point.y - first_point.y));
}
Point::y
int y
Point respect to x coordinate.
Definition: line_segment_intersection.cpp:14

## on_segment()

bool SegmentIntersection::on_segment | ( | Point | first_point,
|  | Point | second_point,
|  | Point | third_point
| ) |  |

inline

This method determines whether a point known to be colinear with a segment lies on that segment.

{
if (std::min(first_point.x, second_point.x) <= third_point.x &&
third_point.x <= std::max(first_point.x, second_point.x) &&
std::min(first_point.y, second_point.y) <= third_point.y &&
third_point.y <= std::max(first_point.y, second_point.y))
return true;
else
return false;
}
std::max
T max(T... args)
std::min
T min(T... args)
Here is the call graph for this function:

The documentation for this struct was generated from the following file:

- geometry/line_segment_intersection.cpp