3/30/2023 0 Comments Iscribe circle inside rhombusTo check if there actually was an overlap, you must check if the intersection happens on your line segment. Although, this is not certain in the case of concave polygons. If there exist two solutions, say x i and x j, then there might be an overlap. Mathematically, this happens when the discriminant is zero. You stated this is still considered to be inside the polygon in your case. If the equation has a single solution, that is both solution are the same, then the circle may touch, but does not leak out of the edge. Otherwise, you can mathematically check the sign of the discriminant as this case happens if it is negative. With high-level languages, you can catch some kind of MathError exception to detect that. This indicates there exists no intersection with this vertex. You can solve that with the quadratic formula for each vertex. This is nothing but a quadratic equation that can be rewritten as: Thus the intersection with a line y = ax + b is found by solving: Let's first remember some formulas we will need.Įquation for a circle of radius r centred at (x 0, y 0): The last check is a necessary condition for the circle to be inside, although it is not sufficient as it is possible that all edges be outside the circle, but that the circle still leaks out of a vertice. If the above does not hold for any edge, then either there is an intersection between the polygon and the circle or the polygon is itself fully inside the circle. , e n of the polygon, a necessary condition is thus that for all i = r Given the circle of radius r and centered at c and the edges e 0, e 1. In particular this ensures that the polygon is not fully inside the circle. Early checkįor the circle to be fully inside the polygon, we need all edges to be outside the circle. This solution works for concave polygons as well. There are a few things you want to check as your definition that touching the vertices is ok adds some cornercases. The following assumes you already know that the center of the circle is inside the polygon.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |