I want to use Vectors in a C# application I'm writing, sepcifically a Vector3.
What's the best way for me to get a Vector type without writing my own?
Vectors are a modern programming concept, which, unfortunately, aren't built into the standard C library. Vectors are same as dynamic arrays with the ability to resize itself automatically when an element is inserted or deleted, with their storage being handled automatically by the container.
A vector type represents a vector of as many of the specified C data type as will fit in a 128-bit register. Hence, the vector signed int is a 128-bit operand containing four 32-bit signed ints . The vector unsigned short is a 128-bit operand containing eight unsigned values.
Given a vector, you can determine its type with typeof() , or check if it's a specific type with an “is” function: is. character() , is. double() , is.
Vector data types are defined by the type name (char, uchar, ushort, int, uint, float, long, and ulong) followed by a literal value n which corresponds to the number of elements in the vector. These data types work with standard C operators, such as +, -, and *.
I used one in a POC that I found on CodeProject. It's not ideal, but it worked for our situation. At the time, however, it did not have a method to reflect a Vector3 about a given normal, but that may have changed since then.
If you don't mind using DirectX (some stay away from it for whatever reason), then there is a Vector3 type in that library as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With