add Jenkinsfile and update prminitives

This commit is contained in:
2021-02-12 12:35:14 +01:00
parent 90c540fb4f
commit f7bedb8ccb
2 changed files with 60 additions and 3 deletions
+36 -3
View File
@@ -1,4 +1,4 @@
from typing import List
from typing import List, Iterable
import solid as scad
@@ -10,9 +10,16 @@ import logging as log
log.basicConfig(level=log.INFO)
def round_box(x_dim: float, y_dim: float, z_dim: float, radius: float, segments: int = 32):
"""creates a round box with radius r
"""
creates a round box with radius r
.. image:: img/round_box.png
Args:
x_dim (float): .
Important:
deprecated
.. image:: img/round_box.png
"""
box = scad.cube([x_dim - 2 * radius, y_dim - 2 * radius, z_dim - 2 * radius])
wall = scad.sphere(r=radius, segments=segments)
@@ -21,6 +28,29 @@ def round_box(x_dim: float, y_dim: float, z_dim: float, radius: float, segments:
scad.minkowski()(box, wall)
)
def rcube(dim: Iterable[float], radius: float, segments: int = 32):
"""
creates a cube with rounded corners
.. image:: img/round_box.png
Args:
dim: cube dimensions to base box on.
radius: box radius.
segments: circular object segments
"""
corners = []
for dx in [radius, dim[0] - radius]:
for dy in [radius, dim[1] - radius]:
for dz in [radius, dim[2] - radius]:
corners.append(
scad.translate([dx, dy, dz])((
scad.sphere(r=radius)
))
)
return scad.hull()(*corners)
def round_flat_box(x: float, y: float, z: float, r: float, segments: int = 32):
"""creates a round box with radius r and flat top/bottom
@@ -36,6 +66,9 @@ def round_flat_box(x: float, y: float, z: float, r: float, segments: int = 32):
def pill(ps: List[List[float]], r, segments: int = 36):
"""
create a pill around given points
"""
if len(ps) < 2:
raise Exception("requires 2 or more points")
s = scad.sphere(r=r, segments=segments)