Skip to content

gb_math: gb_rectX_union #23

@jimon

Description

@jimon

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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions