Add adding and subtraction operations between a number and a quaternion;#18911
Add adding and subtraction operations between a number and a quaternion;#18911opencv-pushbot merged 1 commit intoopencv:masterfrom
Conversation
|
@vpisarev Please take a look. |
|
@chargerKong, the introduced operations are potentially dangerous, because there is no way to guarantee that "S" is scalar value, and it's not "cv::Scalar", "cv::Rect", "cv::Mat" etc. To resolve possible ambiguity, I suggest to add the following operations instead: If needed, add the same operations for |
|
Thank you for your code review @vpisarev. If "S" is not float or double or int, the implemetation of these functions will finally raise an error, because we have limited the elements for generating quaternion must be float or double. So I think maybe it's OK. |
|
@chargerKong, right, but from our experience with template functions in OpenCV this is still a potential problem. |
|
OK. I have one last question. What if we add some limitation in these funcition? @vpisarev |
|
IMHO, to avoid unclear operations (without documentation) it is better to introduce |
|
Thanks for your code review @alalek I want to stick to use these operators and could add the documentation in detail. Because these kind of operations are easy to read and understand. This is the symbols which we have used in papers and the daily writing by hand. What do you think? |
|
@chargerKong, if such a static_assert passes buildbot, i.e. compiles with every compiler that we use now, this is good solution. Also, can you please add into the regression test at least one case where double scalar is added to floating-point quaternion, e.g. 1.3 + Quatf(1.f, 1.f, 1.f, 1.f)? I expect that some compilers will produce warnings for such operation because of missing type casts in the constructor calls. |
IMHO, both types should be equal. BTW, |
|
@chargerKong, it's fine with me, it will also automatically eliminate my concerns about possible ambiguity in the future |
931c1e0 to
c8bf0bf
Compare
| //! @endcond | ||
|
|
||
| #endif /*OPENCV_CORE_QUATERNION_INL_HPP*/ | ||
| #endif /*OPENCV_CORE_QUATERNION_INL_HPP*/ No newline at end of file |
There was a problem hiding this comment.
please keep single empty "new line"
There was a problem hiding this comment.
Do you mean to create a new empty line at the end?
There was a problem hiding this comment.
Yes, files should have with single "new line" symbol in the end (resolved)
|
👍 |
|
@chargerKong, could you, please, squash the commits into one: |
fix a typo; Add documentation of quaternion operators; Restrict the type of scalar: the same as quaternion;
|
thank you! |
I found that many papers directly write a number plus a quaternion.
It has to write like this
which is too much trouble for users. So adding this operations may be friendly and convenience
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.