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

Geometry #18

Open
2 of 7 tasks
felselva opened this issue Nov 15, 2017 · 1 comment
Open
2 of 7 tasks

Geometry #18

felselva opened this issue Nov 15, 2017 · 1 comment

Comments

@felselva
Copy link
Owner

felselva commented Nov 15, 2017

I think it would be useful to have functions to detect intersection between primitives:

For 2D:

  • Point × Circle
  • Point × Triangle
  • Circle × Circle
  • Circle × Triangle
  • Triangle × Triangle

For 3D:

  • Line segment × Triangle
  • Triangle × Triangle

Then, more complex shapes would be only a combination of those. For example, intersection between rectangles would be checking 4 triangles.

Preliminary design for the functions:

bool circle_circle_intersect(struct vec circle_position1, float radius1,
	struct vec circle_position1, float radius1,
	struct contact *result);

bool circle_triangle_intersect(struct vec circle_position, float radius,
	struct vec a, struct vec b, struct vec c,
	struct contact *result);

bool triangle_triangle_intersect(struct vec a1, struct vec b1, struct vec c1,
	struct vec a2, struct vec b2, struct vec c2,
	struct contact *result);

I don't think it would be worth to add a new structure (for example, struct triangle) just for this case. But, a contact structure is probably necessary, since two primitives can have multiple contact points (multiple vectors):

struct contact {
	uint32_t count;
	struct vec v[6];
};
@cxong
Copy link
Contributor

cxong commented Jan 17, 2018

AABB overlap would be handy, it's much simpler than general case box overlap and is a common operation.

@felselva felselva changed the title 2D and 3D primitives intersection Geometry Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants