Skip to content

Warning fixes for quaternion headers#21319

Merged
alalek merged 2 commits intoopencv:4.xfrom
savuor:backport_levmarqfromscratch
Dec 24, 2021
Merged

Warning fixes for quaternion headers#21319
alalek merged 2 commits intoopencv:4.xfrom
savuor:backport_levmarqfromscratch

Conversation

@savuor
Copy link
Copy Markdown
Contributor

@savuor savuor commented Dec 22, 2021

Backport to 4.x from #21018

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@savuor savuor mentioned this pull request Dec 22, 2021
12 tasks
Quat<T> r = Quat<T>::createFromAngleAxis(angle, axis);
Quat<T> t{0, trans[0], trans[1], trans[2]};
return createFromQuat(r, t * r / 2);
return createFromQuat(r, t * r / T(2.0));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use * 0.5f

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, fixed to * 0.5

inline Vec<T, 3> DualQuat<T>::getTranslation(QuatAssumeType assumeUnit) const
{
Quat<T> trans = 2.0 * (getDualPart() * getRealPart().inv(assumeUnit));
Quat<T> trans = T(2.0) * (getDualPart() * getRealPart().inv(assumeUnit));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0f ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T type can be float or double, so what's the point of using f postfix?

Copy link
Copy Markdown
Member

@alalek alalek Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f suffix makes number of float type.
AFAIK, there is no issues with both operations float*float or float*double (the second result is double).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's understood; the problem is that this is not float*float or float*double, this is float*Quat<T> where T can be both.
No wonder using 2.0f breaks compilation on my machine (fails to find corresponding operator).

I propose to leave this code as it is now.

@alalek alalek merged commit 3048188 into opencv:4.x Dec 24, 2021
@savuor savuor deleted the backport_levmarqfromscratch branch December 25, 2021 14:00
@alalek alalek mentioned this pull request Dec 30, 2021
@alalek alalek mentioned this pull request Feb 22, 2022
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
Warning fixes for quaternion headers

* warning fixes for quaternion headers

* a/T(x) => a * T(1/x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants