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

gb_math: gb_rectX_union #23

Open
jimon opened this issue Mar 21, 2017 · 0 comments
Open

gb_math: gb_rectX_union #23

jimon opened this issue Mar 21, 2017 · 0 comments

Comments

@jimon
Copy link
Contributor

jimon commented Mar 21, 2017

Hey, as I'm continue to develop a game based on gb_math, I find that rect unions are pretty much quite useful. Would be nice to have them in standard gb_math. So far I'm using something like this:

gbRect2 gb_rect2_union(gbRect2 a, gbRect2 b)
{
	float tlx = gb_min(a.pos.x, b.pos.x);
	float tly = gb_min(a.pos.y, b.pos.y);
	float brx = gb_max(a.pos.x + a.dim.x, b.pos.x + b.dim.x);
	float bry = gb_max(a.pos.y + a.dim.y, b.pos.y + b.dim.y);
	return gb_rect2(gb_vec2(tlx, tly), gb_vec2(brx - tlx, bry - tly));
}
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

1 participant