From 1ffb26165ff2aa8c5bd71e3184f2591adbfbe19b Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sun, 31 May 2020 13:23:01 +0000 Subject: [PATCH] formatting source-code for 15ec4c3aba4fb41b81ed2b44b7154a4f7b45a898 --- geometry/line_segment_intersection.cpp | 60 +++++++++++++------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/geometry/line_segment_intersection.cpp b/geometry/line_segment_intersection.cpp index 0b5b858d7..f386c5623 100644 --- a/geometry/line_segment_intersection.cpp +++ b/geometry/line_segment_intersection.cpp @@ -20,57 +20,59 @@ struct Point { */ struct SegmentIntersection { inline bool intersect(Point first_point, Point second_point, - Point third_point, Point forth_point) { + Point third_point, Point forth_point) { int direction1 = direction(third_point, forth_point, first_point); int direction2 = direction(third_point, forth_point, second_point); int direction3 = direction(first_point, second_point, third_point); int direction4 = direction(first_point, second_point, forth_point); - if ((direction1 < 0 || direction2 > 0) && (direction3 < 0 || - direction4 > 0)) + if ((direction1 < 0 || direction2 > 0) && + (direction3 < 0 || direction4 > 0)) return true; - else if (direction1 == 0 && on_segment(third_point, forth_point, - first_point)) + else if (direction1 == 0 && + on_segment(third_point, forth_point, first_point)) return true; - else if (direction2 == 0 && on_segment(third_point, forth_point, - second_point)) + else if (direction2 == 0 && + on_segment(third_point, forth_point, second_point)) return true; - else if (direction3 == 0 && on_segment(first_point, second_point, - third_point)) + else if (direction3 == 0 && + on_segment(first_point, second_point, third_point)) return true; - else if (direction3 == 0 && on_segment(first_point, second_point, - forth_point)) + else if (direction3 == 0 && + on_segment(first_point, second_point, forth_point)) return true; else return false; } - /** - * 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. - */ + /** + * 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. + */ inline int direction(Point first_point, Point second_point, - Point third_point) { - 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 third_point) { + 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)); } - /** - * This method determines whether a point known to be colinear - * with a segment lies on that segment. - */ + /** + * This method determines whether a point known to be colinear + * with a segment lies on that segment. + */ inline bool on_segment(Point first_point, Point second_point, - Point third_point) { + Point third_point) { 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 && @@ -96,6 +98,6 @@ int main() { std::cin >> forth_point.x >> forth_point.y; printf("%d", segment.intersect(first_point, second_point, third_point, - forth_point)); + forth_point)); std::cout << std::endl; }