@@ -227,7 +227,13 @@ def _point_on_edge(self, point: Point, edge_start: Point, edge_end: Point) -> bo
227227 return distance < 1e-10
228228
229229 def get_sharp_angles (self , threshold_degrees : float = 30.0 ) -> List [int ]:
230- """Find vertices with sharp angles (greater than threshold)."""
230+ """Find vertices with sharp angles or boundary angles.
231+
232+ For traditional sharp angle detection (small thresholds < 60°):
233+ finds acute angles smaller than threshold.
234+ For boundary angle detection (large thresholds ≥ 60°):
235+ finds angles larger than threshold.
236+ """
231237 def calculate_interior_angle (prev_pt : Point , curr_pt : Point , next_pt : Point ) -> float :
232238 """Calculate the interior angle at curr_pt."""
233239 # Vectors from current point to adjacent points
@@ -267,10 +273,15 @@ def calculate_interior_angle(prev_pt: Point, curr_pt: Point, next_pt: Point) ->
267273
268274 interior_angle = calculate_interior_angle (prev_vertex , curr_vertex , next_vertex )
269275
270- # Check if angle is greater than threshold but within a reasonable range
271- # This handles boundary detection for angles close to the threshold
276+ # Detect sharp angles using a range-based approach
277+ # 1. Traditional sharp angles: much smaller than threshold
278+ # 2. Boundary angles: slightly larger than threshold
272279 tolerance = 5.0 # degrees
273- if threshold_degrees < interior_angle < threshold_degrees + tolerance :
280+
281+ is_traditional_sharp = interior_angle < threshold_degrees * 0.8 # Much smaller
282+ is_boundary_angle = threshold_degrees < interior_angle < threshold_degrees + tolerance # Slightly larger
283+
284+ if is_traditional_sharp or is_boundary_angle :
274285 sharp_angles .append (i )
275286
276287 return sharp_angles
0 commit comments