-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
feat: added a new algorithm to find whether two line segment intersec… #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -0,0 +1,63 @@ | |||
#include <bits/stdc++.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use <bits/stdc++.h>
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
class Point{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use a struct
if all the members are public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpplint_modified_files is failling
geometry/line_segment_intersection.cpp:2: Do not use namespace using-directives. Use using-declarations instead. [build/namespaces] [5]
geometry/line_segment_intersection.cpp:5: public: should be indented +1 space inside class Point [whitespace/indent] [3]
geometry/line_segment_intersection.cpp:10: public: should be indented +1 space inside class SegmentIntersection [whitespace/indent] [3]
geometry/line_segment_intersection.cpp:11: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:11: Missing space before { [whitespace/braces] [5]
geometry/line_segment_intersection.cpp:13: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:17: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:17: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:18: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:20: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:21: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:23: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:24: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:26: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:27: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:29: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:30: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:32: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:37: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:37: Missing space before { [whitespace/braces] [5]
geometry/line_segment_intersection.cpp:38: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
geometry/line_segment_intersection.cpp:38: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:39: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:42: Lines should be <= 80 characters long [whitespace/line_length] [2]
geometry/line_segment_intersection.cpp:43: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- repository is meant for educational purposes and hence, the codes submitted must be educative i.e., others should be able to read and learn from them. This would require the code to be documented as much as possible.
- please ensure that you have performed the sanity checks mentioned in the pull request template. one of them is to READ the CONTRIBUTIONS.md file. Therein is a mention that the files should conform to
cpplint
and all the help for the same is also mentioned. - Please review the protocols and make the necessary corrections.
@@ -0,0 +1,63 @@ | |||
#include <bits/stdc++.h> | |||
using namespace std; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fails cpplint
. must be removed.
int x, y; | ||
}; | ||
|
||
class SegmentIntersection{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this all looks good but do one more thing add a breif documentation for each function, it will help the reader to understand the code in better way
Please see the file |
This looks much better, thank you. |
Excellent. Now, the beginning of the file should contain a comment block like so: /**
* \file
* \brief -- Brief one line comment here
* \description -- optional multiline large description here
*/ |
also, the comment blocks should go just above the function declaration |
int x, y; | ||
}; | ||
|
||
struct SegmentIntersection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this struct is undocumented
@@ -0,0 +1,88 @@ | |||
#include <iostream> | |||
|
|||
struct Point { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct is undocumented.
you can add a brief comment like so: others/smallest_circle
struct SegmentIntersection { | ||
inline bool intersect(Point first_point, Point second_point, | ||
Point third_point, Point forth_point) { | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment blocks should go above the function name i.e. for example, the comment block between lines 10-14 should be just above line 8.
|
||
inline int direction(Point first_point, Point second_point, | ||
Point third_point) { | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same - comment block from lines 46-54 should be at line 44.
} | ||
}; | ||
|
||
int main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document the main function. a simple one-liner is good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be a one line gap between end of a previous code and start of a new comment/code. But the cpplint
does not seem to give any errors regarding that. So, I approve as well.
Good work, @meSajied Thank you
Can you merge this pull request now @kvedala?? |
return false; | ||
} | ||
}; | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
/** |
* or not. | ||
*/ | ||
#include <iostream> | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* | |
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything else looks good
I think everything is good now.... @ayaankhan98 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes looks fine
Reason why we need a robust CI - build fails on windows due to missing |
But now pull request is merged... @kvedala |
you can recreate a pull request with corrections. If you make a pull request - here, it will compile and check your code automatically but I have already fixed your code there. Thats how I found out. Otherwise, it is impossible for one man to compile and check each every one of 100+ programs |
…t or not
Description of Change
Checklist
Notes: