What's the most widely used 2D, 3D, and 4D vector and matrix library for Rust?

What's the most widely used 23, 3D, and 4D vector and matrix library for Rust?
There's "mint":

Looks like a great idea, but did it cach on? Is it widely used? Is it used by the Vulkan API, Vulkano? Game engines?

This, roughly, is the functionality I'm looking for.

http://www.animats.com/source/graphics/algebra3.h

Not some enormous game engine of which this is a tiny part.

1 Like

nalgebra by the rustsim team is IIUC the "default" solution for linalg types.

Note that mint is an interopability crate only; it doesn't provide any functionality beyond holding data. You can look at its rdeps to see which crates support it; euclid and cgmath seem to be the main alternatives to nalgebra.

If you'd use other stuff from rustsim (e.g. ncollide, nphysics), then I'd go with nalgebra. If you'd use some other building block that prefers speaking some other linalg types, I'd use that one. If you're just using the linalg bits and building the rest yourself, pick the one with your favorite API.

Or if you're feeling adventurous, use the mint types and make traits to add functionality to them (and live with the fact you can't implement operator support).


Also, it's worth noting that nalgebra has nalgebra-glm, which is a simplified API to nalgebra for computer graphics inspired by GLM.


One last honorable mention: ultraviolet.


Later edit: I should also mention glam, which is used by bevy. https://github.com/bitshifter/mathbench-rs shows a comparison between the major ecosystem linalg crates.

This is no longer just suggesting a "most widely used" crate, so sorry about that. But the fact is that there isn't one best solution here, so there are going to always be multiple solutions available.

3 Likes

OK, thanks. Hoped that this had been standardized before divergence occurred, but apparently not.

(I have a large C++ program with four different forms of "vector", one for each external package that needed vectors. Too many conversion functions. Hoped to avoid a repeat of that.)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.