ScLERP placement interpolation

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
Post Reply
User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

ScLERP placement interpolation

Post by DeepSOIC » Fri Oct 11, 2019 10:36 am

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.

User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: ScLERP placement interpolation

Post by DeepSOIC » Fri Oct 11, 2019 11:07 am

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.

User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: ScLERP placement interpolation

Post by DeepSOIC » Fri Oct 11, 2019 8:23 pm

Demo! I've just pushed a Lattice2 feature demoing the function. Works only in PR branch FreeCAD.
sclerp-demo.FCStd
(11.72 KiB) Downloaded 23 times
sclerp-demo.png
sclerp-demo.png (40.56 KiB) Viewed 740 times
sclerp-demo-extrapolate.png
sclerp-demo-extrapolate.png (40.95 KiB) Viewed 735 times

User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: ScLERP placement interpolation

Post by DeepSOIC » Fri Oct 11, 2019 11:36 pm

I noticed, there is a test failure of my branch
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)]
Seems, I broke number protocol, placement power doesn't accept integer. I'll try to fix.

User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: ScLERP placement interpolation

Post by DeepSOIC » Sat Oct 12, 2019 12:51 pm

Thanks to spreadsheet unit tests, I feel like the code is ready now.

wmayer
Site Admin
Posts: 16452
Joined: Thu Feb 19, 2009 10:32 am

Re: ScLERP placement interpolation

Post by wmayer » Sat Oct 12, 2019 1:40 pm

Awesome!

wmayer
Site Admin
Posts: 16452
Joined: Thu Feb 19, 2009 10:32 am

Re: ScLERP placement interpolation

Post by wmayer » Sat Oct 12, 2019 2:36 pm

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?

User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: ScLERP placement interpolation

Post by DeepSOIC » Sat Oct 12, 2019 3:29 pm

wmayer wrote:
Sat Oct 12, 2019 2:36 pm
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?
Yes, I think I just screwed this up :oops:

User avatar
DeepSOIC
Posts: 7810
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: ScLERP placement interpolation

Post by DeepSOIC » Sat Oct 12, 2019 3:45 pm

wmayer wrote:
Sat Oct 12, 2019 2:36 pm
Could we harmonize it to be more consistent?
https://github.com/FreeCAD/FreeCAD/pull/2613

wmayer
Site Admin
Posts: 16452
Joined: Thu Feb 19, 2009 10:32 am

Re: ScLERP placement interpolation

Post by wmayer » Sat Oct 12, 2019 6:35 pm

Thanks!

Post Reply