@@ -1392,12 +1392,6 @@ def testRectArray(self):
1392
1392
def testPolarArray (self ):
1393
1393
radius = 10
1394
1394
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
-
1401
1395
to_x = lambda l : l .wrapped .Transformation ().TranslationPart ().X ()
1402
1396
to_y = lambda l : l .wrapped .Transformation ().TranslationPart ().Y ()
1403
1397
to_angle = (
@@ -1408,23 +1402,27 @@ def testPolarArray(self):
1408
1402
1409
1403
# Test for proper placement when fill == True
1410
1404
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 ]))
1413
1408
1414
1409
# Test for proper placement when angle to fill is multiple of 360 deg
1415
1410
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 ]))
1418
1414
1419
1415
# Test for proper placement when fill == False
1420
1416
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 ]))
1423
1420
1424
1421
# Test for proper operation of startAngle
1425
1422
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 ]))
1428
1426
1429
1427
# Test for local rotation
1430
1428
s = Workplane ().polarArray (radius , 0 , 180 , 3 )
@@ -1435,6 +1433,21 @@ def testPolarArray(self):
1435
1433
self .assertAlmostEqual (0 , to_angle (s .objects [0 ]))
1436
1434
self .assertAlmostEqual (0 , to_angle (s .objects [1 ]))
1437
1435
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
+
1438
1451
def testNestedCircle (self ):
1439
1452
s = (
1440
1453
Workplane ("XY" )
@@ -2003,6 +2016,15 @@ def testPolarLines(self):
2003
2016
self .assertEqual (1 , r .wires ().size ())
2004
2017
self .assertEqual (5 , r .wires ().edges ().size ())
2005
2018
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
+
2006
2028
def testLargestDimension (self ):
2007
2029
"""
2008
2030
Tests the largestDimension function when no solids are on the stack and when there are
0 commit comments