Question

I'm developing an application involving math and physics models, and I'd like to use a Math library for things like Matrices. I'm using C#, and so I was looking for some libraries and found Math.NET. I'm under the impression, from past experience, that for math, using a robust and industry-approved third party library is much better than writing your own code.

It seems good for many purposes, but it does not provide support for Quaternions, which I need to use as a type. Also, I need some functions in Vector and Matrix that also aren't provided, such as rotation matrices and vector rotation functions, and calculating cross products. At the same time, it provides a lot of functions/classes that I simply do not need, which might mean a lot of unnecessary bloat and complexity.

At this rate, should I even bother using the library? Should I write my own math library? Or is it a better idea to stick to the third party library and somehow wrap around it? Perhaps I should make a subclass of the Matrix and Vector type of the library? But isn't that considered bad style?

I've also tried looking for other libraries but unfortunately I couldn't find anything suitable.

Was it helpful?

Solution

Write the classes you need using the library. Once you have proper code and tests in place, offer to contribute those classes back into the library, since MathDotNet seems to be an open source project.

Just to make things clear, using the library to write those functionalities you find missing does not mean to modify the library's source code to patch it on your own. It means importing the library in your code, and using its existing functions to save as much work as possible while developing your new classes. You can later isolate those changes and create a patch for the library out of them.

Also, to clarify license matters: the MIT license of MathDotNet does not force you to contribute your changes. But it is a Good Thing to share, it lifts the burden of maintaining your changes from your own shoulders, and it helps prevent a future where every C# developer has his/her own Quaternion implementation.

Licensed under: CC-BY-SA with attribution
scroll top