MCPcopy
hub / github.com/CadQuery/cadquery / polarArray

Method polarArray

cadquery/cq.py:1436–1487  ·  view source on GitHub ↗

Creates a polar array of points and pushes them onto the stack. The zero degree reference angle is located along the local X-axis. :param radius: Radius of the array. :param startAngle: Starting angle (degrees) of array. Zero degrees is situated along th

(
        self: T,
        radius: float,
        startAngle: float,
        angle: float,
        count: int,
        fill: bool = True,
        rotate: bool = True,
    )

Source from the content-addressed store, hash-verified

1434 return self.pushPoints(lpoints)
1435
1436 def polarArray(
1437 self: T,
1438 radius: float,
1439 startAngle: float,
1440 angle: float,
1441 count: int,
1442 fill: bool = True,
1443 rotate: bool = True,
1444 ) -> T:
1445 """
1446 Creates a polar array of points and pushes them onto the stack.
1447 The zero degree reference angle is located along the local X-axis.
1448
1449 :param radius: Radius of the array.
1450 :param startAngle: Starting angle (degrees) of array. Zero degrees is
1451 situated along the local X-axis.
1452 :param angle: The angle (degrees) to fill with elements. A positive
1453 value will fill in the counter-clockwise direction. If fill is
1454 False, angle is the angle between elements.
1455 :param count: Number of elements in array. (count >= 1)
1456 :param fill: Interpret the angle as total if True (default: True).
1457 :param rotate: Rotate every item (default: True).
1458 """
1459
1460 if count < 1:
1461 raise ValueError(f"At least 1 element required, requested {count}")
1462
1463 # Calculate angle between elements
1464 if fill:
1465 if abs(math.remainder(angle, 360)) < TOL:
1466 angle = angle / count
1467 else:
1468 # Inclusive start and end
1469 angle = angle / (count - 1) if count > 1 else startAngle
1470
1471 locs = []
1472
1473 # Add elements
1474 for i in range(0, count):
1475 phi_deg = startAngle + (angle * i)
1476 phi = math.radians(phi_deg)
1477 x = radius * math.cos(phi)
1478 y = radius * math.sin(phi)
1479
1480 if rotate:
1481 loc = Location(Vector(x, y), Vector(0, 0, 1), phi_deg)
1482 else:
1483 loc = Location(Vector(x, y))
1484
1485 locs.append(loc)
1486
1487 return self.pushPoints(locs)
1488
1489 def pushPoints(self: T, pntList: Iterable[Union[VectorLike, Location]]) -> T:
1490 """

Callers 1

testPolarArrayMethod · 0.80

Calls 4

pushPointsMethod · 0.95
LocationClass · 0.85
VectorClass · 0.85
appendMethod · 0.80

Tested by 1

testPolarArrayMethod · 0.64