trenchfoot 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of trenchfoot might be problematic. Click here for more details.

@@ -128,6 +128,7 @@ def _offset_closed_polyline(path: List[Tuple[float,float]], offset: float) -> Li
128
128
  raise ValueError("Closed polyline needs at least 3 points")
129
129
 
130
130
  # Compute tangents treating path as closed loop
131
+ # For CCW-oriented polygons, use CW rotation to get outward-pointing normals
131
132
  tangents = []
132
133
  normals = []
133
134
  for i in range(n):
@@ -135,7 +136,7 @@ def _offset_closed_polyline(path: List[Tuple[float,float]], offset: float) -> Li
135
136
  if np.linalg.norm(t) < 1e-12:
136
137
  t = np.array([1.0, 0.0])
137
138
  tangents.append(t)
138
- normals.append(_rotate_ccw(t))
139
+ normals.append(_rotate_cw(t)) # CW rotation gives outward normal for CCW polygon
139
140
 
140
141
  # Compute offset points with proper miter at each vertex
141
142
  offset_pts = []
@@ -546,6 +547,64 @@ def make_sphere(center: np.ndarray, radius: float, n_theta: int=48, n_phi: int=2
546
547
  def _ring_from_LR(L: List[np.ndarray], R: List[np.ndarray]) -> np.ndarray:
547
548
  return np.array(L + list(R[::-1]), float)
548
549
 
550
+
551
+ def _ring_from_LR_with_end_caps(
552
+ L: List[np.ndarray], R: List[np.ndarray],
553
+ path_xy: List[Tuple[float, float]], end_extension: float, n_cap_points: int = 5
554
+ ) -> np.ndarray:
555
+ """Create a ring from L/R offsets with semicircular end caps.
556
+
557
+ Extends the outer boundary past the path endpoints to create ground buffer
558
+ at the ends of open trenches.
559
+ """
560
+ P = np.array(path_xy, float)
561
+
562
+ # Get tangent directions at endpoints
563
+ t_start = _normalize(P[1] - P[0])
564
+ t_end = _normalize(P[-1] - P[-2])
565
+
566
+ # Start cap: semicircle from R[0] around to L[0], extending in -t_start direction
567
+ # Center of cap is at path start, offset backward by end_extension
568
+ cap_center_start = P[0] - end_extension * t_start
569
+ # Radius is distance from center to L[0] or R[0]
570
+ radius_start = np.linalg.norm(np.array(L[0]) - cap_center_start)
571
+
572
+ # Generate semicircle points from R[0] to L[0] going around the back
573
+ # R[0] is at angle theta_r, L[0] is at angle theta_l
574
+ # We go from theta_r counterclockwise to theta_l (the long way around the back)
575
+ vec_r = np.array(R[0]) - cap_center_start
576
+ vec_l = np.array(L[0]) - cap_center_start
577
+ theta_r = np.arctan2(vec_r[1], vec_r[0])
578
+ theta_l = np.arctan2(vec_l[1], vec_l[0])
579
+
580
+ # Ensure we go the "back" way (counterclockwise from R to L)
581
+ if theta_l > theta_r:
582
+ theta_l -= 2 * np.pi
583
+
584
+ angles_start = np.linspace(theta_r, theta_l, n_cap_points + 2)[1:-1] # Exclude endpoints (already have R[0], L[0])
585
+ cap_start = [cap_center_start + radius_start * np.array([np.cos(a), np.sin(a)]) for a in angles_start]
586
+
587
+ # End cap: semicircle from L[-1] around to R[-1], extending in +t_end direction
588
+ cap_center_end = P[-1] + end_extension * t_end
589
+ radius_end = np.linalg.norm(np.array(L[-1]) - cap_center_end)
590
+
591
+ vec_l_end = np.array(L[-1]) - cap_center_end
592
+ vec_r_end = np.array(R[-1]) - cap_center_end
593
+ theta_l_end = np.arctan2(vec_l_end[1], vec_l_end[0])
594
+ theta_r_end = np.arctan2(vec_r_end[1], vec_r_end[0])
595
+
596
+ # Go counterclockwise from L[-1] to R[-1] (the back way)
597
+ if theta_r_end > theta_l_end:
598
+ theta_r_end -= 2 * np.pi
599
+
600
+ angles_end = np.linspace(theta_l_end, theta_r_end, n_cap_points + 2)[1:-1]
601
+ cap_end = [cap_center_end + radius_end * np.array([np.cos(a), np.sin(a)]) for a in angles_end]
602
+
603
+ # Build the full ring: L + end_cap + R_reversed + start_cap
604
+ ring_points = list(L) + cap_end + list(R[::-1]) + cap_start
605
+
606
+ return np.array(ring_points, float)
607
+
549
608
  def make_trench_from_path_sloped(path_xy: List[Tuple[float,float]], width_top: float, depth: float, wall_slope: float, ground) -> Tuple[Dict,str,str,dict]:
550
609
  # Build top and bottom rings by offsetting centerline
551
610
  half_top = width_top/2.0
@@ -763,8 +822,8 @@ def make_ground_surface_plane(path_xy: List[Tuple[float,float]], width_top: floa
763
822
  the trench opening as an open hole. This creates a natural shape that
764
823
  hugs L-shaped, U-shaped, and curved trenches.
765
824
 
766
- For closed paths (like circles), also creates a center island inside
767
- the inner edge of the annular trench.
825
+ For closed paths (like circles), the ground surface is a ring around the
826
+ outer edge of the trench, with the trench opening left completely open.
768
827
  """
769
828
  half_top = width_top / 2.0
770
829
  m = float(max(0.5, ground.size_margin))
@@ -772,47 +831,36 @@ def make_ground_surface_plane(path_xy: List[Tuple[float,float]], width_top: floa
772
831
  is_closed = _is_path_closed(path_xy)
773
832
 
774
833
  if is_closed:
775
- # For closed paths, we have:
776
- # - Outer ground: annulus from ground_outer to trench_outer
777
- # - Center island: filled polygon inside trench_inner
834
+ # For closed paths (like circular wells), the ground is an annulus
835
+ # from the outer ground boundary to the outer edge of the trench opening.
836
+ # The center (inside the trench) is left completely open.
778
837
 
779
- # Trench boundaries
838
+ # Trench outer boundary (edge of trench opening)
780
839
  trench_outer = np.array(_offset_closed_polyline(path_xy, half_top), float)
781
- trench_inner = np.array(_offset_closed_polyline(path_xy, -half_top), float)
782
840
 
783
- # Ground outer boundary
841
+ # Ground outer boundary (edge of ground surface)
784
842
  ground_outer = np.array(_offset_closed_polyline(path_xy, half_top + m), float)
785
843
 
786
844
  # Ensure proper orientations
787
845
  trench_outer = _ensure_ccw(trench_outer)
788
- trench_inner = _ensure_ccw(trench_inner)
789
846
  ground_outer = _ensure_ccw(ground_outer)
790
847
 
791
- # Outer ground annulus
792
- outer_combined_xy, outer_tris = _triangulate_annulus(ground_outer, trench_outer)
793
- outer_Vg = np.array([[x, y, gfun(x, y)] for (x, y) in outer_combined_xy], float)
794
-
795
- # Center island (simple filled polygon)
796
- center_tris = _ear_clipping_triangulation(trench_inner)
797
- center_Vg = np.array([[x, y, gfun(x, y)] for (x, y) in trench_inner], float)
798
-
799
- # Combine into single ground surface
800
- n_outer_verts = len(outer_Vg)
801
- center_tris_offset = center_tris + n_outer_verts
802
-
803
- Vg = np.vstack([outer_Vg, center_Vg])
804
- tris = np.vstack([outer_tris, center_tris_offset])
848
+ # Ground annulus: from ground_outer to trench_outer
849
+ combined_xy, tris = _triangulate_annulus(ground_outer, trench_outer)
850
+ Vg = np.array([[x, y, gfun(x, y)] for (x, y) in combined_xy], float)
805
851
 
806
852
  return {"ground_surface": (Vg, tris)}
807
853
  else:
808
- # Original logic for open paths
854
+ # Open paths: ground forms annulus with end caps extending past trench endpoints
809
855
  # Inner boundary: the trench opening (same as trench top ring)
810
856
  L_inner, R_inner = _offset_polyline(path_xy, half_top)
811
857
  inner_ring = _ensure_ccw(_ring_from_LR(L_inner, R_inner))
812
858
 
813
- # Outer boundary: offset by additional margin
859
+ # Outer boundary: offset by additional margin, with semicircular end caps
814
860
  L_outer, R_outer = _offset_polyline(path_xy, half_top + m)
815
- outer_ring = _ensure_ccw(_ring_from_LR(L_outer, R_outer))
861
+ outer_ring = _ensure_ccw(_ring_from_LR_with_end_caps(
862
+ L_outer, R_outer, path_xy, end_extension=m
863
+ ))
816
864
 
817
865
  # Triangulate the annular region (leaves hole open)
818
866
  combined_xy, tris = _triangulate_annulus(outer_ring, inner_ring)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trenchfoot
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Synthetic trench scenario generator bundle (surfaces + volumetrics).
5
5
  Author: Liam Moore
6
6
  License-File: LICENSE
@@ -6,7 +6,7 @@ trenchfoot/gmsh_sloped_trench_mesher.py,sha256=D7EL6V0wkE6tvDARmm006yZE6KEzCl25O
6
6
  trenchfoot/plot_mesh.py,sha256=26dOlVfaM1WsUfr_sXVqA7axtY9qjY3WCNM7cUBTS7Q,3810
7
7
  trenchfoot/render_colors.py,sha256=EfldvoshgaZ6iZFk-UDL67-tvwGYaiZFS2NQZBMwhDM,1596
8
8
  trenchfoot/scene_spec_example.json,sha256=UcV25ku422UO0ZZPDrJwrT1zwmjoOIpnBdLuEdh-AZA,1028
9
- trenchfoot/trench_scene_generator_v3.py,sha256=gNYT_D8-7kI23RGCQeBCXG0lJTwttGKKuCy1diNoOR4,43324
9
+ trenchfoot/trench_scene_generator_v3.py,sha256=EDG_ChbnDEbLiIU0GsA5IfWmuknQDUTx2DRiL5lEv4k,45665
10
10
  trenchfoot/scenarios/SUMMARY.json,sha256=PUT7ID4nl5BJ6A0M3MhbOkx5bm2HAy0Gwzq8cc6JBAE,18492
11
11
  trenchfoot/scenarios/S01_straight_vwalls/metrics.json,sha256=_AoK-WCgTKKdu_zUJL-HiSnsxMJvr6GDxlet7Ojmtk4,691
12
12
  trenchfoot/scenarios/S01_straight_vwalls/preview.png,sha256=adsx3-6oMu9WaixggXRhuXi_KM-q5s2RNSBLR_stq80,199624
@@ -71,8 +71,8 @@ trenchfoot/scenarios/S07_circular_well/preview_top.png,sha256=XW7DQLDEYmSV6Lnfo1
71
71
  trenchfoot/scenarios/S07_circular_well/scene.json,sha256=bvror2YX6aNbsEc25-N7JO3ysH2dTLGyEE6zGzZysXQ,3146
72
72
  trenchfoot/scenarios/S07_circular_well/trench_scene.obj,sha256=1MAsyGkJ4-tCRXLDWi_7ruumgpCpcl_Ca5poRLtTua0,1619846
73
73
  trenchfoot/scenarios/S07_circular_well/volumetric/trench_volume.msh,sha256=dqhtd3SFKj5RLT_BcWIIvVGCbAqvOx7RX25-K7NKX10,615212
74
- trenchfoot-0.2.2.dist-info/METADATA,sha256=32oD4purZc8D9BqvfiYh6Tj--UaJD6VXXMo9LQfxcc8,5292
75
- trenchfoot-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
76
- trenchfoot-0.2.2.dist-info/entry_points.txt,sha256=5TejAGmc4GnNYLn7MhhLtSCNz9240RvzcNaetF4IHfg,119
77
- trenchfoot-0.2.2.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
78
- trenchfoot-0.2.2.dist-info/RECORD,,
74
+ trenchfoot-0.2.4.dist-info/METADATA,sha256=6OadSF2ZjBflziGJrQxUQMLNwIy9QDwyr3J03BJneiA,5292
75
+ trenchfoot-0.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
76
+ trenchfoot-0.2.4.dist-info/entry_points.txt,sha256=5TejAGmc4GnNYLn7MhhLtSCNz9240RvzcNaetF4IHfg,119
77
+ trenchfoot-0.2.4.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
78
+ trenchfoot-0.2.4.dist-info/RECORD,,