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

Line2.Collinear function not work right. #213

Closed
0smile opened this issue Jul 11, 2021 · 4 comments
Closed

Line2.Collinear function not work right. #213

0smile opened this issue Jul 11, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@0smile
Copy link

0smile commented Jul 11, 2021

Environment

  • OS Version: <Ubuntu 20.04>
  • Source or binary build?
    <binary, math6.8>

Description

  • Expected behavior: I'm using the function 'Collinear' of the class 'Line2'. Ideally it should calculate the cross product of two lines using the function Line2.CrossProduct, and than compare the product with 0 using the math::equal function. However it doesn't work right.
  • Actual behavior: While I make from the source code, it shows 'error: no matching function for call to ‘equal(double, int, double&)’. I think it is because that Line2.CrossProduct returns a double number, but the math::equal can not compare the double with a int 0.

Steps to reproduce

  1. type: line1.Collinear(line2)
  2. make from the source code.

Output

In file included from /usr/include/ignition/math6/ignition/math.hh:41,
                 from /home/shaw/Desktop/ignition/math/test.cpp:3:
/usr/include/ignition/math6/ignition/math/Line2.hh: In instantiation of ‘bool ignition::math::v6::Line2<T>::Parallel(const ignition::math::v6::Line2<T>&, double) const [with T = int]’:
/usr/include/ignition/math6/ignition/math/Line2.hh:140:22:   required from ‘bool ignition::math::v6::Line2<T>::Collinear(const ignition::math::v6::Line2<T>&, double) const [with T = int]’
/home/shaw/Desktop/ignition/math/test.cpp:14:32:   required from here
**/usr/include/ignition/math6/ignition/math/Line2.hh:126:27: error: no matching function for call to ‘equal(double, int, double&)’**
  126 |         return math::equal(this->CrossProduct(_line),
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  127 |             static_cast<T>(0), _epsilon);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/ignition/math6/ignition/math/graph/Vertex.hh:29,
                 from /usr/include/ignition/math6/ignition/math/graph/Edge.hh:28,
                 from /usr/include/ignition/math6/ignition/math.hh:23,
                 from /home/shaw/Desktop/ignition/math/test.cpp:3:
/usr/include/ignition/math6/ignition/math/Helpers.hh:556:17: note: candidate: ‘template<class T> bool ignition::math::v6::equal(const T&, const T&, const T&)’
  556 |     inline bool equal(const T &_a, const T &_b,
      |                 ^~~~~
/usr/include/ignition/math6/ignition/math/Helpers.hh:556:17: note:   template argument deduction/substitution failed:
In file included from /usr/include/ignition/math6/ignition/math.hh:41,
                 from /home/shaw/Desktop/ignition/math/test.cpp:3:
/usr/include/ignition/math6/ignition/math/Line2.hh:126:27: note:   deduced conflicting types for parameter ‘const T’ (‘double’ and ‘int’)
  126 |         return math::equal(this->CrossProduct(_line),
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
  127 |             static_cast<T>(0), _epsilon);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/test.dir/build.make:63: CMakeFiles/test.dir/test.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/test.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
@0smile 0smile added the bug Something isn't working label Jul 11, 2021
@scpeters
Copy link
Member

can you provide a complete c++ file so that I can reproduce the failure?

@0smile
Copy link
Author

0smile commented Jul 11, 2021 via email

@chapulina
Copy link
Contributor

@0smile , are you able to provide a minimal failing example?

@WagnerMarcos
Copy link
Contributor

I have come across this issue, and I am pushing a fix in this PR, with this issue described in the Line2 Issues and notes section. Using 0. (A float type 0) should fix the problem. This issue appears when using a Line2 with the double template

@0smile 0smile closed this as completed Aug 30, 2021
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

4 participants