dagostinelli/hypatia

Why are vectors a struct?

awsdert opened this issue · 1 comments

Looking at the headers I saw this:

struct vector3 {
	union {
		HYP_FLOAT v[3];
		struct {
			HYP_FLOAT x, y, z;
		};
		struct {
			HYP_FLOAT yaw, pitch, roll;
		};
	};
};

Why bother with the outer struct when you could've done this:

union vector3 {
	HYP_FLOAT v[3];
	struct {
		HYP_FLOAT x, y, z;
	};
	struct {
		HYP_FLOAT yaw, pitch, roll;
	};
};

That's an interesting idea.

I used the struct because I thought it was an intuitive choice.