Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a vector type in C#?

Tags:

c#

vector

directx

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?

like image 280
Mendokusai Avatar asked Jan 31 '09 19:01

Mendokusai


People also ask

Can I make a vector in C?

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.

What is vector type in C?

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.

How do you find a vector type?

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.

What is a vector datatype?

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 *.


1 Answers

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.

like image 158
Kilhoffer Avatar answered Sep 24 '22 18:09

Kilhoffer