Skip to content

Conversation

@Djllesh
Copy link

@Djllesh Djllesh commented Feb 10, 2024

By default projects a line onto a circle along the ray, where the ray intersects the line in the middle. Takes additional parameter "end_length" that determines, which fraction of the length of the line is the distance from the end to the intersection point.

Projects the triangle on the circle along the ray that goes through the centroid (median intersection point).

Updated a demo for testing. (Press "c" to project circles, "L" - lines, "t" - triangles).

Inconsistency: the project(triangle, circle) function returns the triangle, not the point. Might be a good idea to just return a projected shape in all cases, rather than a point.

intersect(q, c) returns both intersection points

@Djllesh Djllesh changed the title Implemented project(circle, triangle) Implemented project(line, circle) Feb 12, 2024
@Djllesh Djllesh changed the title Implemented project(line, circle) Implemented project(line, circle) and project(circle, triangle) Feb 12, 2024
@Djllesh Djllesh changed the title Implemented project(line, circle) and project(circle, triangle) Project line and triangle on the circle, project circle on the triangle Feb 16, 2024
@OneLoneCoder
Copy link
Owner

Right, firstly thanks! Secondly, this is an interesting one, because I really like your suggestion of just returning the projected shape, and I think that makes a lot of sense.

  1. It's intuitive, even with std::optional
  2. It allows the shape to be projected relative to the supplied ray. As you have demonstrated, picking a point that "links" the shape to the ray is undefined (and therefore inconsistent) - but it needn't be defined at all if the returned object is the projected shape. I can envisage many cases where you don't want to project the shape directly central to the ray.

Let me know your thoughts, but I think this is the way to go here

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

Successfully merging this pull request may close these issues.

2 participants