Skip to content

Geometry #18

@felselva

Description

@felselva

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions