-
Notifications
You must be signed in to change notification settings - Fork 82
Added Conditions for Slerp vs Squad interpolation #577
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
base: gz-math7
Are you sure you want to change the base?
Changes from 6 commits
b6d7673
9d504f3
c9e01c2
039a64a
7dfe977
cf8b74c
76c57b4
2638fe0
79fda43
cc558a5
1399fd2
d854a85
28b4321
0b0685f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,12 @@ | |
| */ | ||
| #include "gz/math/Quaternion.hh" | ||
| #include "gz/math/RotationSpline.hh" | ||
| #include "cmath" | ||
|
|
||
| using namespace gz; | ||
| using namespace math; | ||
|
|
||
| using namespace std; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this |
||
| /// \internal | ||
| /// \brief Private data for RotationSpline | ||
| class RotationSpline::Implementation | ||
|
|
@@ -88,11 +90,25 @@ Quaterniond RotationSpline::Interpolate(const unsigned int _fromIndex, | |
| // Use squad using tangents we've already set up | ||
| Quaterniond &p = this->dataPtr->points[_fromIndex]; | ||
| Quaterniond &q = this->dataPtr->points[_fromIndex+1]; | ||
| Quaterniond &a = this->dataPtr->tangents[_fromIndex]; | ||
| Quaterniond &b = this->dataPtr->tangents[_fromIndex+1]; | ||
|
|
||
| Vector3d peu(p.Euler()); | ||
| Vector3d qeu(q.Euler()); | ||
|
|
||
| double diffX = abs(peu.X()-qeu.X()); | ||
| double diffY = abs(peu.Y()-qeu.Y()); | ||
| double diffZ = abs(peu.Z()-qeu.Z()); | ||
|
|
||
| // NB interpolate to nearest rotation | ||
| return Quaterniond::Squad(_t, p, a, b, q, _useShortestPath); | ||
| if ((diffX < 0.16) || (diffY < 0.16) || (diffZ < 0.16)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comparing euler angles like this doesn't seem like a safe thing to do. I would suggest calculating the |
||
| { | ||
| return Quaterniond::Slerp(_t, p, q, _useShortestPath); | ||
| } | ||
| else | ||
| { | ||
| Quaterniond &a = this->dataPtr->tangents[_fromIndex]; | ||
| Quaterniond &b = this->dataPtr->tangents[_fromIndex+1]; | ||
| return Quaterniond::Squad(_t, p, a, b, q, _useShortestPath); | ||
| } | ||
| } | ||
|
|
||
| ///////////////////////////////////////////////// | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.