Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

c#

xna

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

Edit: For clarification a XNA C# Vector2/3/4 "structures" (I'm not entirely sure what they are) basically hold 2, 3, or 4 float values like a struct in C++ defined as:

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

I've been basically using just that code in C++, but I was hoping for a standard alternative and was unable to find one.

like image 326
Joe.F Avatar asked Aug 10 '10 15:08

Joe.F


People also ask

What is the standard version of C?

C89. The ANSI standard was completed in 1989 and ratified as ANSI X3. 159-1989 "Programming Language C." This version of the language is often referred to as "ANSI C". Later on sometimes the label "C89" is used to distinguish it from C90 but using the same labeling method.

Are there different versions C?

Let's continue with a discussion of all the five different standards of C — K&R C, ANSI C, C99, C11 and Embedded C. For the purposes of our discussion, the compiler used is the gcc C compiler from the GNU Compiler Collection (GCC). If there are five different standards for C, which one is the default standard of gcc?

Is ANSI C and C same?

ANSI C merely refers to a particular standard for the C Programming Language - i.e. there is no difference, they refer to the same thing.

Is C or C+ Better?

Compared to C, C++ has significantly more libraries and functions to use. If you're working with complex software, C++ is a better fit because you have more libraries to rely on. Thinking practically, having knowledge of C++ is often a requirement for a variety of programming roles.


2 Answers

The Vector3 struct in C# is from XNA, not the base class libraries.

The equivelent in C++ would be to use XMFLOAT3.

like image 166
Reed Copsey Avatar answered Oct 23 '22 03:10

Reed Copsey


Nothing standard that I know of, but here's some code to get you started

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

If you are using C++/CLI and targeting Windows and .NET, you can use Vector2, etc.

like image 41
Lou Franco Avatar answered Oct 23 '22 02:10

Lou Franco