skelterjohn / go.matrix

linear algebra for go
Other
338 stars 72 forks source link

Add float32 functionality. #6

Closed Nvveen closed 11 years ago

Nvveen commented 11 years ago

Using go.matrix for OpenGL calls for example isn't possible without converting each underlying matrix to a float32 slice. It would be nice to see functionality added that allows the user to use this type.

skelterjohn commented 11 years ago

I think that, if you're working with opengl, it'd be better to use a matrix lib written specifically with opengl in mind. That is, only 3x3 or 4x4 matrices, backed by float32s. I know that at least one package like this exists, but I'm having a lot of trouble tracking it down.

I'm not going to built float32 support into go.matrix, but it'd be straightforward and fast to write your own function that, for instance, took a DenseMatrix and turned it into a row-major []float32.

Nvveen commented 11 years ago

Although I think the overhead for such a conversion is too big for OpenGL requirements, I think I agree go.matrix might be a bit much for the user case scenario's OpenGL development entails.

skelterjohn commented 11 years ago

Right. For typical opengl stuff you need only the basic matrix operations - scale, add, multiply. These things will be super fast if you are only dealing with 4x4 matrices and you can hard-code everything. For trickier things that go.matrix can offer, like the various decompositions, the time spent doing the decomp will overwhelm the time spent converting it between formats.

On Tue, Jan 29, 2013 at 10:47 AM, Neal van Veen notifications@github.comwrote:

Although I think the overhead for such a conversion is too big for OpenGL requirements, I think I agree go.matrix might be a bit much for the user case scenario's OpenGL development entails.

— Reply to this email directly or view it on GitHubhttps://github.com/skelterjohn/go.matrix/issues/6#issuecomment-12840904.