I am working on a C# project where I need to rotate some vectors. Until now I was using a rather complicated solution using rotation matrices but now I also need support for quaternion rotation (and probably converting from one to the other).

Most libraries I find are made for graphics developments. I don't need to output/render any graphics, though. The XNA and DirectX reference pages show details about Matrix, Vector3 and Quaternion classes which seem to provide all I need. But those seem to be somehow outdated?

I am really not experienced in this field of libraries and I'm not sure if there are any solutions which are more up-to-date or if this does not really matter.
Of course it would be great if there is any library which is more light-weight, too. Since the rotation should be performed in real-time, the library should have a good performance.

  • So I had a try on this XnaGeometry library which seemed to offer exactly what I needed. But it seems like this is pretty buggy, too, regarding the quaternion rotation. So here I am, looking again for a library.
    – John
    Nov 5 '17 at 13:04
  • Maybe the Math.NET library has what you need? May 25 '21 at 10:00

I ended up using the MonoGame Framework, which is an open source implementation of the XNA framework. I just added the MonoGame.Framework.WindowsDX package to my project which offered the same namespaces as Microsoft's XNA documentation. So I could easily have using Microsoft.Xna.Framework; in my classes to use Quaternion, Matrix and Vector3 objects.

For me, this seems to be a good solution, if you don't need any gaming, graphics or rendering features. You can just add the NuGet package and use the XNA classes you need.


The more obvious choice might have been to use System.Numerics. Alternatively at my company we developed an open-source library Vim.Math3d from System.Numerics combined with many useful algorithms and structures from MonoGame. For completeness we are maintaining a list of similar 3D Math libraries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.