@@ -333,16 +333,38 @@ def set_planar_contour(self, contour_polygon: list):
333
333
raise ValueError (f"contour_polygon.shape[1] { contour_polygon .shape [1 ]} and ndim { self .ndim } do not match!" )
334
334
self .probe_planar_contour = contour_polygon
335
335
336
- def create_auto_shape (self , probe_type : "tip" | "rect" = "tip" , margin : float = 20.0 ):
337
- """Create planar contour automatically based on probe contact positions.
336
+ def create_auto_shape (self , probe_type : "tip" | "rect" | "circular" = "tip" , margin : float = 20.0 ):
337
+ """Create a planar contour automatically based on probe contact positions.
338
+
339
+ This function generates a 2D polygon that outlines the shape of the probe, adjusted
340
+ by a specified margin. The resulting contour is set as the planar contour of the probe.
338
341
339
342
Parameters
340
343
----------
341
- probe_type : "tip" | "rect", default: "tip"
342
- The probe type ('tip' or 'rect')
343
- margin : float, default: 20.0
344
- The margin to add to the contact positions
344
+ probe_type : {"tip", "rect", "circular"}, default: "tip"
345
+ The type of probe used to collect contact data:
345
346
347
+ * "tip": Assumes a single-point contact probe. The generated contour is
348
+ a rectangle with a triangular "tip" extending downwards.
349
+ * "rect": Assumes a rectangular contact probe. The generated contour is
350
+ a rectangle.
351
+ * "circular": Assumes a circular contact probe. The generated contour
352
+ is a circle.
353
+
354
+ margin : float, default: 20.0
355
+ The margin to add around the contact positions. The behavior varies by
356
+ probe type:
357
+
358
+ * "tip": The margin is added around the rectangular portion of the contour
359
+ and to the base of the tip. The tip itself is extended downwards by
360
+ four times the margin value.
361
+ * "rect": The margin is added evenly around all sides of the rectangle.
362
+ * "circular": The margin is added to the radius of the circle.
363
+
364
+ Notes
365
+ -----
366
+ This function is designed for 2D data only. If you have 3D data, consider projecting
367
+ it onto a plane before using this method.
346
368
"""
347
369
if self .ndim != 2 :
348
370
raise ValueError (f"Auto shape is supported only for 2d, you have ndim { self .ndim } " )
@@ -383,8 +405,19 @@ def create_auto_shape(self, probe_type: "tip" | "rect" = "tip", margin: float =
383
405
(x1 , y0 ),
384
406
(x1 , y1 ),
385
407
]
408
+ elif probe_type == "circular" :
409
+ radius_x = (x1 - x0 ) / 2
410
+ radius_y = (y1 - y0 ) / 2
411
+ center = ((x0 + x1 ) / 2 , (y0 + y1 ) / 2 )
412
+ radius = max (radius_x , radius_y ) + margin
413
+ num_vertices = 100
414
+ theta = np .linspace (0 , 2 * np .pi , num_vertices , endpoint = False )
415
+ x = center [0 ] + radius * np .cos (theta )
416
+ y = center [1 ] + radius * np .sin (theta )
417
+ vertices = np .vstack ((x , y )).T
418
+ polygon += vertices .tolist ()
386
419
else :
387
- raise ValueError (f"'probe_type' can only be 'rect' or 'tip , you have entered { probe_type } " )
420
+ raise ValueError (f"'probe_type' can only be 'rect, 'tip' or 'circular' , you have entered { probe_type } " )
388
421
389
422
self .set_planar_contour (polygon )
390
423
0 commit comments