Most convenient method to handle 3D vectors?
I'm looking for a struct/class in which magnitude(L2 norm), normalize, multiplication with a scalar, and dot product are implemented. Thank you.
11 Replies
Vector3 Struct (System.Numerics)
Represents a vector with three single-precision floating-point values.
it seems good
but is there a double-precision version of that?
no, not yet
hmm :(
for something like that i would suggest using a library like https://www.nuget.org/packages/Silk.NET.Maths/
Silk.NET.Maths 2.16.0
Silk.NET is a high-speed, advanced library, providing bindings to popular low-level APIs such as OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, and DirectX.
it has a Vector3<T> that very closely mirrors the one in System.Numerics
it is not SIMD accelerated like S.N.V, but i used it to run a numerical simulation and it at least functioned correctly
it seems really cool
is 'SIMD acceleration' what Vector<T> utilizes to optimize its performance?
yeah. Vector<T> is the most "conventional" SIMD-like type in System.Numerics--it's not a euclidean vector, or really similar to any mathematical object, it's just a thing that lets you do arithmetic on n values at once
got it
Vector2/3/4 have special support in the runtime for register allocation (they use the special hardware vector registers) and many of their operations (e.g. adding vectors can be done with SIMD, since it's just componentwise additions, like Vector<T>), but the hardware doesn't intrinsically support all of the mathematical operations (some can naturally be implemented in terms of others but aren't at the moment. stuff like Cross and the Transform ones in particular, maybe there are a handful of others)
wow you're like a fountain of new knowledge
thank you