{"action":"created","issue":{"url":"https://api.github.com/repos/PointCloudLibrary/pcl/issues/2365","repository_url":"https://api.github.com/repos/PointCloudLibrary/pcl","labels_url":"https://api.github.com/repos/PointCloudLibrary/pcl/issues/2365/labels{/name}","comments_url":"https://api.github.com/repos/PointCloudLibrary/pcl/issues/2365/comments","events_url":"https://api.github.com/repos/PointCloudLibrary/pcl/issues/2365/events","html_url":"https://github.com/PointCloudLibrary/pcl/issues/2365","id":337874918,"node_id":"MDU6SXNzdWUzMzc4NzQ5MTg=","number":2365,"title":"Plane coefficient comparator compares angles wrong","user":{"login":"Kaju-Bubanja","id":6259829,"node_id":"MDQ6VXNlcjYyNTk4Mjk=","avatar_url":"https://avatars0.githubusercontent.com/u/6259829?v=4","gravatar_id":"","url":"https://api.github.com/users/Kaju-Bubanja","html_url":"https://github.com/Kaju-Bubanja","followers_url":"https://api.github.com/users/Kaju-Bubanja/followers","following_url":"https://api.github.com/users/Kaju-Bubanja/following{/other_user}","gists_url":"https://api.github.com/users/Kaju-Bubanja/gists{/gist_id}","starred_url":"https://api.github.com/users/Kaju-Bubanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kaju-Bubanja/subscriptions","organizations_url":"https://api.github.com/users/Kaju-Bubanja/orgs","repos_url":"https://api.github.com/users/Kaju-Bubanja/repos","events_url":"https://api.github.com/users/Kaju-Bubanja/events{/privacy}","received_events_url":"https://api.github.com/users/Kaju-Bubanja/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-03T12:20:15Z","updated_at":"2018-07-03T13:39:45Z","closed_at":null,"author_association":"NONE","body":"<!--- WARNING: This is an issue tracker, please use our mailing list for questions: www.pcl-users.org. -->\r\n\r\n<!--- Provide a general summary of the issue in the Title above -->\r\nLooking at the plane_coefficient comparator [here\r\n](https://github.com/PointCloudLibrary/pcl/blob/master/segmentation/include/pcl/segmentation/plane_coefficient_comparator.h) regarding the compare method on line 182-200 I think the comparison of the angles is wrong. I think the line 199 should be \r\n`&& (1.0 - fabs(normals_->points[idx1].getNormalVector3fMap ().dot (normals_->points[idx2].getNormalVector3fMap () )) < angular_threshold_)\r\n`\r\n## Your Environment\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n* Operating System and version: Ubuntu 16.04\r\n* Compiler: gcc\r\n* PCL Version: 1.8\r\n\r\n## Context\r\n<!--- How has this issue affected you? What are you trying to accomplish? -->\r\n<!--- Providing context helps us come up with a solution that is most useful in the real world -->\r\nI'm trying to use the multiple plane segmentation algorithm and tried to improve it, while looking at the code I found this potential bug.\r\n\r\n## Expected Behavior\r\n<!--- If you're describing a bug, tell us what should happen -->\r\n<!--- If you're suggesting a change/improvement, tell us how it should work -->\r\nI propose this as a fix:\r\n` (1.0 - fabs(normals_->points[idx1].getNormalVector3fMap ().dot (normals_->points[idx2].getNormalVector3fMap () )) < angular_threshold_)\r\n`\r\n\r\n## Current Behavior\r\n<!--- If describing a bug, tell us what happens instead of the expected behavior -->\r\n<!--- If suggesting a change/improvement, explain the difference from current behavior -->\r\nThis small snippet shows an example where the result is wrong:\r\n\r\n```cpp\r\nbool compare ()\r\n{\r\n  double angular_threshold_ = pcl::deg2rad(2.0);\r\n  Eigen::Vector3f a(0,0,1);\r\n  Eigen::Vector3f b(0,sqrt(0.75),0.5);\r\n  double angle = pcl::rad2deg(acos(b.dot (a)));\r\n  std::cout << angle << std::endl;\r\n  return (b.dot (a) > angular_threshold_ );\r\n}\r\n```\r\n\r\n## Code to Reproduce\r\n<!--- Provide a link to a live example, or an unambiguous set of steps to -->\r\n<!--- reproduce this bug. Include code to reproduce, if relevant -->\r\nThis small snippet shows an example where the result is wrong:\r\n```cpp\r\nbool compare ()\r\n{\r\n  double angular_threshold_ = pcl::deg2rad(2.0);  \r\n\r\n  Eigen::Vector3f a(0,0,1);  \r\n  Eigen::Vector3f b(0,sqrt(0.75),0.5);  \r\n  double angle = pcl::rad2deg(acos(b.dot (a)));  \r\n  std::cout << angle << std::endl;  \r\n  return (b.dot (a) > angular_threshold_ );  \r\n}\r\n```\r\n\r\n## Possible Solution\r\n<!--- Not obligatory, but suggest a fix/reason for the bug, -->\r\n<!--- or ideas how to implement the addition or change -->\r\nI propose this as a fix:\r\n` (1.0 - fabs(normals_->points[idx1].getNormalVector3fMap ().dot (normals_->points[idx2].getNormalVector3fMap () )) < angular_threshold_)\r\n`"},"comment":{"url":"https://api.github.com/repos/PointCloudLibrary/pcl/issues/comments/402160787","html_url":"https://github.com/PointCloudLibrary/pcl/issues/2365#issuecomment-402160787","issue_url":"https://api.github.com/repos/PointCloudLibrary/pcl/issues/2365","id":402160787,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjE2MDc4Nw==","user":{"login":"Kaju-Bubanja","id":6259829,"node_id":"MDQ6VXNlcjYyNTk4Mjk=","avatar_url":"https://avatars0.githubusercontent.com/u/6259829?v=4","gravatar_id":"","url":"https://api.github.com/users/Kaju-Bubanja","html_url":"https://github.com/Kaju-Bubanja","followers_url":"https://api.github.com/users/Kaju-Bubanja/followers","following_url":"https://api.github.com/users/Kaju-Bubanja/following{/other_user}","gists_url":"https://api.github.com/users/Kaju-Bubanja/gists{/gist_id}","starred_url":"https://api.github.com/users/Kaju-Bubanja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kaju-Bubanja/subscriptions","organizations_url":"https://api.github.com/users/Kaju-Bubanja/orgs","repos_url":"https://api.github.com/users/Kaju-Bubanja/repos","events_url":"https://api.github.com/users/Kaju-Bubanja/events{/privacy}","received_events_url":"https://api.github.com/users/Kaju-Bubanja/received_events","type":"User","site_admin":false},"created_at":"2018-07-03T13:39:45Z","updated_at":"2018-07-03T13:39:45Z","author_association":"NONE","body":"Because if the normals are not all orientated the same way you might get -1. I had this when I wanted to compare every point normal to the already found plane equation in the segment step."}}
{"actor":{"display_login":"Kaju-Bubanja"}}