azul3d / engine

Azul3D - A 3D game engine written in Go!
https://azul3d.org
Other
606 stars 54 forks source link

lmath: mat4 doesn't provide determinant #147

Closed dskinner closed 8 years ago

dskinner commented 8 years ago

I was noticing lmath.Mat4 doesn't provide determinant. This is useful for checking where a point lies in comparison to a sphere (used in 3D delaunay triangulation)

I have the really boring math here which could be copy/pasted https://github.com/dskinner/tds/blob/master/tds.go#L106

I have a test that indirectly tests determinant here: https://github.com/dskinner/tds/blob/master/tds_test.go#L47 by way of this function https://github.com/dskinner/tds/blob/master/tds.go#L168 though I'm not sure how that would fit in to lmath.

I can submit a pull request for a mat4.Determinant if it's agreeable.

slimsag commented 8 years ago

I can submit a pull request for a mat4.Determinant if it's agreeable.

That sounds great to me! I like the naming Det for the method BTW. At least one test, would be nice too.

This is useful for checking where a point lies in comparison to a sphere (used in 3D delaunay triangulation)

I was actually trying to look into CDT (Constrained Delaunay Triangulation) a while back for triangulating the inner regions of vector graphics splines (like those from a font) but couldn't figure it out and ended up trying to go with a stencil buffer approach. Did you manage to create any working DT code? I'd love to take a look for my own personal reference!

dskinner commented 8 years ago

well I did an initial 2D version which is in the tds package i linked. I have some of the core methods for doing 3D in there but need to write the data store for it as well (I just happen to need something more efficient than directed edges in a hashmap). I have an android app, source not available b/c its a mess, that uses tds and inserts points everywhere you touch and drag, inside and out. There's still a couple things to address in the 2D, and the 3D isn't a much further stretch since most of the logic is very similar.

I'm reading this book which covers a lot of theory but also gives practical advice for implementation in pseudo code: https://books.google.com/books?id=oJ3SBQAAQBAJ&num=13

I'll try and put together a pull request later this evening for mat4 Det.