Skip to content
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

isIntersect2D nad getIntersection2D vector bug #1115

Closed
TauTheLepton opened this issue Oct 24, 2023 · 2 comments
Closed

isIntersect2D nad getIntersection2D vector bug #1115

TauTheLepton opened this issue Oct 24, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@TauTheLepton
Copy link
Contributor

Describe the bug
The functions isIntersect2D and getIntersection2D have implementation bug.

for (size_t i = 0; i <= lines.size(); i++) {
for (size_t m = 0; m <= lines.size(); m++) {

for (size_t i = 0; i <= lines.size(); i++) {
for (size_t m = 0; m <= lines.size(); m++) {

All for loops above look past the last element of the lines vector which causes the function to work incorrectly.
The comparison operator in the loops condition should be changed from <= to < in order to check all of the elements and not more.

Context:
I am adding unit tests for the geometry package and wanted to add tests for these functions, but the functions mentioned above produce incorrect results and I believe the mentioned for loop issues is the cause for the incorrect behavior.

To Reproduce
Steps to reproduce the behavior:

  1. Write any code using the functions mentioned above (the ones accepting std::vector as argument)
  2. See the incorrect result

Expected behavior
Functions do produce the correct result (e.g. line from (0, 0) to (1, 1) does not intersect line from point (1, 0) to (2, 1) ).

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]: Ubuntu
  • Browser [e.g. chrome, safari]: Firefox
  • Version [e.g. 22]: 22
  • ROS 2 version: Humble
  • DDS: CycloneDDS
@hakuturu583
Copy link
Collaborator

Thanks, it was my mistake.

@hakuturu583 hakuturu583 self-assigned this Oct 25, 2023
@hakuturu583 hakuturu583 added the bug Something isn't working label Oct 26, 2023
@hakuturu583
Copy link
Collaborator

#1139 was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants