@@ -1392,12 +1392,6 @@ def testRectArray(self):
13921392 def testPolarArray (self ):
13931393 radius = 10
13941394
1395- # Test for proper number of elements
1396- s = Workplane ("XY" ).polarArray (radius , 0 , 180 , 1 )
1397- self .assertEqual (1 , s .size ())
1398- s = Workplane ("XY" ).polarArray (radius , 0 , 180 , 6 )
1399- self .assertEqual (6 , s .size ())
1400-
14011395 to_x = lambda l : l .wrapped .Transformation ().TranslationPart ().X ()
14021396 to_y = lambda l : l .wrapped .Transformation ().TranslationPart ().Y ()
14031397 to_angle = (
@@ -1408,23 +1402,27 @@ def testPolarArray(self):
14081402
14091403 # Test for proper placement when fill == True
14101404 s = Workplane ("XY" ).polarArray (radius , 0 , 180 , 3 )
1411- self .assertAlmostEqual (0 , to_y (s .objects [1 ]))
1412- self .assertAlmostEqual (radius , to_x (s .objects [1 ]))
1405+ self .assertEqual (3 , s .size ())
1406+ self .assertAlmostEqual (radius , to_x (s .objects [0 ]))
1407+ self .assertAlmostEqual (0 , to_y (s .objects [0 ]))
14131408
14141409 # Test for proper placement when angle to fill is multiple of 360 deg
14151410 s = Workplane ("XY" ).polarArray (radius , 0 , 360 , 4 )
1416- self .assertAlmostEqual (0 , to_y (s .objects [1 ]))
1417- self .assertAlmostEqual (radius , to_x (s .objects [1 ]))
1411+ self .assertEqual (4 , s .size ())
1412+ self .assertAlmostEqual (radius , to_x (s .objects [0 ]))
1413+ self .assertAlmostEqual (0 , to_y (s .objects [0 ]))
14181414
14191415 # Test for proper placement when fill == False
14201416 s = Workplane ("XY" ).polarArray (radius , 0 , 90 , 3 , fill = False )
1421- self .assertAlmostEqual (0 , to_y (s .objects [1 ]))
1422- self .assertAlmostEqual (radius , to_x (s .objects [1 ]))
1417+ self .assertEqual (3 , s .size ())
1418+ self .assertAlmostEqual (- radius , to_x (s .objects [2 ]))
1419+ self .assertAlmostEqual (0 , to_y (s .objects [2 ]))
14231420
14241421 # Test for proper operation of startAngle
14251422 s = Workplane ("XY" ).polarArray (radius , 90 , 180 , 3 )
1426- self .assertAlmostEqual (radius , to_x (s .objects [0 ]))
1427- self .assertAlmostEqual (0 , to_y (s .objects [0 ]))
1423+ self .assertEqual (3 , s .size ())
1424+ self .assertAlmostEqual (0 , to_x (s .objects [0 ]))
1425+ self .assertAlmostEqual (radius , to_y (s .objects [0 ]))
14281426
14291427 # Test for local rotation
14301428 s = Workplane ().polarArray (radius , 0 , 180 , 3 )
@@ -1435,6 +1433,21 @@ def testPolarArray(self):
14351433 self .assertAlmostEqual (0 , to_angle (s .objects [0 ]))
14361434 self .assertAlmostEqual (0 , to_angle (s .objects [1 ]))
14371435
1436+ with raises (ValueError ):
1437+ Workplane ().polarArray (radius , 20 , 180 , 0 )
1438+
1439+ s = Workplane ().polarArray (radius , 20 , 0 , 1 )
1440+ assert s .size () == 1
1441+ assert Workplane ().polarLine (radius , 20 ).val ().positionAt (
1442+ 1
1443+ ).toTuple () == approx (s .val ().toTuple ()[0 ])
1444+
1445+ s = Workplane ().center (2 , - 4 ).polarArray (2 , 10 , 50 , 3 ).rect (1.0 , 0.5 ).extrude (1 )
1446+ assert s .solids ().size () == 3
1447+ assert s .vertices (">Y and >Z" ).val ().toTuple () == approx (
1448+ (3.0334936490538906 , - 1.7099364905389036 , 1.0 )
1449+ )
1450+
14381451 def testNestedCircle (self ):
14391452 s = (
14401453 Workplane ("XY" )
@@ -2003,6 +2016,15 @@ def testPolarLines(self):
20032016 self .assertEqual (1 , r .wires ().size ())
20042017 self .assertEqual (5 , r .wires ().edges ().size ())
20052018
2019+ r = Workplane ().polarLineTo (1 , 20 )
2020+ assert r .val ().positionAt (1 ).toTuple () == approx (
2021+ (0.9396926207859084 , 0.3420201433256687 , 0.0 )
2022+ )
2023+ r = Workplane ().move (1 , 1 ).polarLine (1 , 20 )
2024+ assert r .val ().positionAt (1 ).toTuple () == approx (
2025+ (1.9396926207859084 , 1.3420201433256687 , 0.0 )
2026+ )
2027+
20062028 def testLargestDimension (self ):
20072029 """
20082030 Tests the largestDimension function when no solids are on the stack and when there are
0 commit comments