Skip to content

isIntersect2D nad getIntersection2D vector bug #1115

Closed
@TauTheLepton

Description

@TauTheLepton

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions