ScLERP placement interpolation
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
ScLERP placement interpolation
PR #2609
While I'd like to test this a bit more, there are a few things to discuss.
My implementation is slightly different from that in http://www.xbdev.net/misc_demos/demos/d ... /paper.pdf
* Special handling of no-rotation situation (because normalization multiplier becomes infinite in this situation, breaking the algorithm).
* Dual quaternions are implemented as a collection of dual numbers, rather than a collection of two quaternions like it is done in suggested inplementation in the paper. The main reason for doing so is because a) quaternion math is already partly implemented in Rotation, so repeating it is kinda silly. b) I see potential of dual numbers elsewhere, particularly in sketcher.
* acos replaced with atan2 for improved angle accuracy for small angles
consequently, I have implemented a dual number. Then at some point I realized there may be existing implementatios worthy to be re-used.
I have looked at https://github.com/tesch1/cxxduals . It's a header-only implementation of dual numbers, with Eigen and CUDA compatibility. What I don't like about it is that the code is not readable. I didn't search much beyond this.
Also I have seen some existing DualQuaternion libraries, along with some other supermath. Maybe they are too worth considering.
Also. Should I absolutely make unit tests into this PR? Maybe better yes, as I may fail to be motivated to write the tests if the PR is merged.
While I'd like to test this a bit more, there are a few things to discuss.
My implementation is slightly different from that in http://www.xbdev.net/misc_demos/demos/d ... /paper.pdf
* Special handling of no-rotation situation (because normalization multiplier becomes infinite in this situation, breaking the algorithm).
* Dual quaternions are implemented as a collection of dual numbers, rather than a collection of two quaternions like it is done in suggested inplementation in the paper. The main reason for doing so is because a) quaternion math is already partly implemented in Rotation, so repeating it is kinda silly. b) I see potential of dual numbers elsewhere, particularly in sketcher.
* acos replaced with atan2 for improved angle accuracy for small angles
consequently, I have implemented a dual number. Then at some point I realized there may be existing implementatios worthy to be re-used.
I have looked at https://github.com/tesch1/cxxduals . It's a header-only implementation of dual numbers, with Eigen and CUDA compatibility. What I don't like about it is that the code is not readable. I didn't search much beyond this.
Also I have seen some existing DualQuaternion libraries, along with some other supermath. Maybe they are too worth considering.
Also. Should I absolutely make unit tests into this PR? Maybe better yes, as I may fail to be motivated to write the tests if the PR is merged.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: ScLERP placement interpolation
Also. While implementing DualQuat, I thought it would have been nice to implement it as a template against the type of number it uses. Same for DualNumber. But I didn't, mostly because I was a bit lazy, and I'm not comfortable with templates yet. Should I do it?
Right now, DualQuat has a few methods special only to it being dual, real() and dual() for example. And a bunch of handy constructors. I don't even know if it is possible to do with template version.
Right now, DualQuat has a few methods special only to it being dual, real() and dual() for example. And a bunch of handy constructors. I don't even know if it is possible to do with template version.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: ScLERP placement interpolation
Demo! I've just pushed a Lattice2 feature demoing the function. Works only in PR branch FreeCAD.
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: ScLERP placement interpolation
I noticed, there is a test failure of my branch
Seems, I broke number protocol, placement power doesn't accept integer. I'll try to fix.Traceback (most recent call last):
File "S:\_vt\dev\PC\Qt\FreeCAD\build-release\bin\lib\unittest\case.py", line 59, in testPartExecutor
yield
File "S:\_vt\dev\PC\Qt\FreeCAD\build-release\bin\lib\unittest\case.py", line 605, in run
testMethod()
File "S:\_vt\dev\PC\Qt\FreeCAD\build-release\Mod\Spreadsheet\TestSpreadsheet.py", line 940, in testMatrix
self.assertEqual(sheet.B4,ipla*ipla)
File "S:\_vt\dev\PC\Qt\FreeCAD\build-release\bin\lib\unittest\case.py", line 829, in assertEqual
assertion_func(first, second, msg=msg)
File "S:\_vt\dev\PC\Qt\FreeCAD\build-release\bin\lib\unittest\case.py", line 822, in _baseAssertEqual
raise self.failureException(msg)
AssertionError: 'ERR: Not implemented\nA4 ^ -2' != Placement [Pos=(2,-2,-4.82843), Yaw-Pitch-Roll=(0,-90,-0)]
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: ScLERP placement interpolation
Thanks to spreadsheet unit tests, I feel like the code is ready now.
Re: ScLERP placement interpolation
Awesome!
Re: ScLERP placement interpolation
Small remark: the order of arguments in the Python wrapper is different to the C++ function and different to the slerp() function of the Rotation class. Could we harmonize it to be more consistent?