tbrosman / hxmath

A math library for Haxe.
MIT License
92 stars 10 forks source link

DualQuaternion #59

Closed nanjizal closed 4 years ago

nanjizal commented 4 years ago

Hi Thomas

I have been working on my geom math library, someone suggested I use yours instead but I think they do pretty similar. Anyway thought it's probably good idea to connect on ideas from time to time eg:

I noticed you don't have a DualQuaternion class - would you like a pull request for one, I could probably adapt mine for your library. I built my library because I wanted to move away from dependancy on kha.math library and I tend to use a lot more abstract ( like my 'triangulations' port ), have tried to add methods related to triangulation and so some stuff needs tidying, but looks like some of our code has similar design structure.

I have gone with StrucInit's, as for JS they don't seem to add overhead ? But they do allow you to often pass parameters more clearly, and even in js I found typedef seemed slower. Also I quite liked luxe's old approach of structs everywhere.

https://github.com/nanjizal/geom/blob/master/src/geom/matrix/DualQuaternion.hx

( You can see DualQuaternions and Matrix4x3 used in my Dice experiment. )

Also my Complex class maybe of interest: https://github.com/nanjizal/geom/blob/master/src/geom/matrix/Complex.hx

By the way if you have any feedback on my library please feel free to get in touch, a lot of my maths is likely rusty and I suspect my code could be tidied up a lot. Flat is mostly included because it is essential to trilateral2 and seemed more generic than trilateral2 but eventually I may use gluon the GL library's typed arrays.

Best Justin

nanjizal commented 4 years ago

I don't know much about your Frame stuff but it looks like similar to a DualQuaternion in that I can just write arm * forearm * finger to get a position and the order does not matter.

tbrosman commented 4 years ago

I would love a DualQuaternion class! Feel free to open a PR. Same goes for Complex. I pared down my initial set of types mostly for complexity/maintenance reasons. At this point I have the test coverage/documentation I want for existing types.

The Frame classes are my attempt to add semantics to the math. I think to make them more useful I need to adopt an existing passive/active transform naming convention. Dual Quaternions are great for concatenation, but don't have a convenient "frame" representation: you have to do math to extract the translation/rotation (e.g. a full quaternion multiplication just to get the translation).

As for struct inits, they actually pre-date this library. I have been using them a lot in my later code. Maybe in some future breaking change I'll switch. They make things like Matrix4x4 construction a lot nicer.