Is there a standard C ++ equivalent of C # Vector3?

Just wondering if C ++ has the standard equivalent of Vector2 / 3/4 (the structures I think?) In C #?

Edit: to explain the structure of XNA C # Vector2 / 3/4 "(I'm not quite sure what it is) basically contain 2, 3 or 4 float values, such as a structure in C ++ defined as:

struct Vector3 { float x, y, z; }; 

Mostly I used only this C ++ code, but I was hoping for a standard alternative and could not find it.

+7
c ++ c # xna
source share
6 answers

Nothing standard that I know, but here is some code to get you started

http://www.flipcode.com/archives/Faster_Vector_Math_Using_Templates.shtml

If you use C ++ / CLI and target Windows and .NET, you can use Vector2 etc.

+3
source share

Vector # struct in C # is an XNA, not a base class library.

The equalizer in C ++ will use XMFLOAT3 .

+5
source share

Although there is no Vector3 equivalent in standard C ++, there are several linear algebra libraries that have one. Some of them are very small and fast:

+2
source share

A valarray<complex<T>> can be used as a Vector2 in many cases. For Vector3/4 I do not know the standard equivalent.

0
source share

I do not believe that in C ++ there are some "canned" objects that are equivalent. STL vector is not the same thing. This is essentially a dynamic array for storing any type of value, while the vector you are referring to belongs to the class with added functionality, which is usually used in XNA graphics applications (at least in my experience). You are on something with your recognition of the fact that Vector2 / 3/4 are data structures. You can very easily save the values โ€‹โ€‹of the W, X, Y, Z components in your own structure, but the added member functions provided with the Vector2 / 3/4 object must be added by you.

0
source share

There are also several C ++ graphical libraries similar to XNA, such as Ogre3D , Irrlicht, and others. Maybe a bit overkill if you need a Vector3 structure.

0
source share

All Articles