Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why are vectors a struct? #11

Open
awsdert opened this issue Jun 25, 2021 · 1 comment
Open

Why are vectors a struct? #11

awsdert opened this issue Jun 25, 2021 · 1 comment

Comments

@awsdert
Copy link

awsdert commented Jun 25, 2021

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;
	};
};
@dagostinelli
Copy link
Owner

That's an interesting idea.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants