@@ -128,6 +128,8 @@ def intersections_plane(
128
128
Position of plane in x direction, only one of x,y,z can be specified to define plane.
129
129
z : float = None
130
130
Position of plane in x direction, only one of x,y,z can be specified to define plane.
131
+ transpose : bool = False
132
+ Optional: Swap the coordinates in the plane normal to the axis before creating each shape?
131
133
132
134
Returns
133
135
-------
@@ -471,13 +473,15 @@ def _do_intersections_tilted_plane(
471
473
path , _ = section .to_planar (to_2D = to_2D )
472
474
return path .polygons_full
473
475
474
- def _intersections_normal (self , z : float ):
476
+ def _intersections_normal (self , z : float , transpose : bool = False ):
475
477
"""Find shapely geometries intersecting cylindrical geometry with axis normal to slab.
476
478
477
479
Parameters
478
480
----------
479
481
z : float
480
482
Position along the axis normal to slab
483
+ transpose : bool = False
484
+ Optional: Swap the x and y coordinates?
481
485
482
486
Returns
483
487
-------
@@ -495,10 +499,10 @@ def _intersections_normal(self, z: float):
495
499
if radius_offset <= 0 :
496
500
return []
497
501
498
- _ , (x0 , y0 ) = self .pop_axis (static_self .center , axis = self .axis )
502
+ _ , (x0 , y0 ) = self .pop_axis (static_self .center , axis = self .axi , transpose = transpose )
499
503
return [shapely .Point (x0 , y0 ).buffer (radius_offset , quad_segs = _N_SHAPELY_QUAD_SEGS )]
500
504
501
- def _intersections_side (self , position , axis ):
505
+ def _intersections_side (self , position , axis , transpose : bool = False ):
502
506
"""Find shapely geometries intersecting cylindrical geometry with axis orthogonal to length.
503
507
When ``sidewall_angle`` is nonzero, so that it's in fact a conical frustum or cone, the
504
508
cross section can contain hyperbolic curves. This is currently approximated by a polygon
@@ -510,6 +514,8 @@ def _intersections_side(self, position, axis):
510
514
Position along axis direction.
511
515
axis : int
512
516
Integer index into 'xyz' (0, 1, 2).
517
+ transpose : bool = False
518
+ Optional: Swap the coordinates in the plane orthogonal to the axis?
513
519
514
520
Returns
515
521
-------
@@ -534,8 +540,8 @@ def _intersections_side(self, position, axis):
534
540
# the vertices on the max side of top/bottom
535
541
# The two vertices are present in all scenarios.
536
542
vertices_max = [
537
- self ._local_to_global_side_cross_section ([- intersect_half_length_max , 0 ], axis ),
538
- self ._local_to_global_side_cross_section ([intersect_half_length_max , 0 ], axis ),
543
+ self ._local_to_global_side_cross_section ([- intersect_half_length_max , 0 ], axis , transpose = transpose ),
544
+ self ._local_to_global_side_cross_section ([intersect_half_length_max , 0 ], axis , transpose = transpose ),
539
545
]
540
546
541
547
# Extending to a cone, the maximal height of the cone
@@ -559,7 +565,7 @@ def _intersections_side(self, position, axis):
559
565
)
560
566
for i in range (_N_SAMPLE_CURVE_SHAPELY ):
561
567
vertices_frustum_right .append (
562
- self ._local_to_global_side_cross_section ([x_list [i ], y_list [i ]], axis )
568
+ self ._local_to_global_side_cross_section ([x_list [i ], y_list [i ]], axis , transpose = transpose )
563
569
)
564
570
vertices_frustum_left .append (
565
571
self ._local_to_global_side_cross_section (
@@ -568,6 +574,7 @@ def _intersections_side(self, position, axis):
568
574
y_list [_N_SAMPLE_CURVE_SHAPELY - i - 1 ],
569
575
],
570
576
axis ,
577
+ transpose = transpose ,
571
578
)
572
579
)
573
580
@@ -578,17 +585,17 @@ def _intersections_side(self, position, axis):
578
585
if intersect_half_length_min > 0 :
579
586
vertices_min .append (
580
587
self ._local_to_global_side_cross_section (
581
- [intersect_half_length_min , self .finite_length_axis ], axis
588
+ [intersect_half_length_min , self .finite_length_axis ], axis , transpose = transpose
582
589
)
583
590
)
584
591
vertices_min .append (
585
592
self ._local_to_global_side_cross_section (
586
- [- intersect_half_length_min , self .finite_length_axis ], axis
593
+ [- intersect_half_length_min , self .finite_length_axis ], axis , transpose = transpose
587
594
)
588
595
)
589
596
## early termination
590
597
else :
591
- vertices_min .append (self ._local_to_global_side_cross_section ([0 , height_max ], axis ))
598
+ vertices_min .append (self ._local_to_global_side_cross_section ([0 , height_max ], axis , transpose = transpose ))
592
599
593
600
return [
594
601
shapely .Polygon (
@@ -735,7 +742,12 @@ def _radius_z(self, z: float):
735
742
736
743
return radius_middle - (z - self .center_axis ) * self ._tanq
737
744
738
- def _local_to_global_side_cross_section (self , coords : list [float ], axis : int ) -> list [float ]:
745
+ def _local_to_global_side_cross_section (
746
+ self ,
747
+ coords : list [float ],
748
+ axis : int ,
749
+ transpose : bool = False ,
750
+ ) -> list [float ]:
739
751
"""Map a point (x,y) from local to global coordinate system in the
740
752
side cross section.
741
753
@@ -750,6 +762,8 @@ def _local_to_global_side_cross_section(self, coords: list[float], axis: int) ->
750
762
Integer index into 'xyz' (0, 1, 2).
751
763
coords : List[float, float]
752
764
The value in the planar coordinate.
765
+ transpose : bool = False
766
+ Optional: Swap the coordinates in the plane before converting them?
753
767
754
768
Returns
755
769
-------
@@ -767,6 +781,7 @@ def _local_to_global_side_cross_section(self, coords: list[float], axis: int) ->
767
781
plane_val = coords [0 ],
768
782
axis_val = axis_sign * (- self .finite_length_axis / 2 + coords [1 ]),
769
783
axis = axis ,
784
+ transpose = transpose ,
770
785
)
771
- _ , (x_center , y_center ) = self .pop_axis (self .center , axis = axis )
786
+ _ , (x_center , y_center ) = self .pop_axis (self .center , axis = axis , transpose = transpose )
772
787
return [x_center + lx_offset , y_center + ly_offset ]
0 commit comments