Generate helixes that can optionally taper to a point at each end.
Project description
Taperable Helix
Generate helixes that can optionally taper to a point at each end.
GitHub repo: https://github.com/winksaville/py-taperable-helix/
Documentation: https://taperable-helix.readthedocs.io/
PyPi package: https://pypi.org/project/taperable-helix/
Free software: MIT license
Package Docs
@dataclass
class Helix:
radius: float
pitch: float
height: float
taper_out_rpos: float = 0
taper_in_rpos: float = 1
inset_offset: float = 0
first_t: float = 0
last_t: float = 1
@dataclass
class HelixLocation:
# The internal thread radius and an array of HelixLocation
radius: Optional[float] = None
horz_offset: float = 0
vert_offset: float = 0
def helix(
h: Helix, hl: Optional[HelixLocation] = None
) -> Callable[[float], Tuple[float, float, float]]:
...
Examples
def helical_line(
radius: float = 5, pitch: float = 2, height: float = 6, num_points: int = 100
) -> List[Tuple[float, float, float]]:
h: Helix = Helix(radius=radius, pitch=pitch, height=height)
f = helix(h)
points = list(map(f, linspace(start=0, stop=1, num=num_points, dtype=float)))
# print(f"helical_line: points={points}")
return points
def helical_triangle(
radius: float = 1,
pitch: float = 2,
height: float = 4,
num_points: int = 100,
tri_height: float = 0.2,
tri_width: float = 0.2,
) -> Tuple[
List[Tuple[float, float, float]],
List[Tuple[float, float, float]],
List[Tuple[float, float, float]],
]:
# Create three helixes that taper to a point
# Create the base Helix
h: Helix = Helix(
radius=radius, pitch=pitch, height=height, taper_out_rpos=0.1, taper_in_rpos=0.9
)
# The Upper points, horz_offset defaults to 0
fU = helix(h, HelixLocation(vert_offset=tri_height / 2))
points_fU = list(map(fU, linspace(h.first_t, h.last_t, num=100, dtype=float)))
# The Lower points, again horz_offset defaults to 0
fL = helix(h, HelixLocation(vert_offset=-tri_height / 2))
points_fL = list(map(fL, linspace(h.first_t, h.last_t, num=100, dtype=float)))
# The Middle point, change vert_offset to 0
fM = helix(h, HelixLocation(horz_offset=tri_width))
points_fM = list(map(fM, linspace(h.first_t, h.last_t, num=100, dtype=float)))
return (points_fU, points_fM, points_fL)
Prerequisites
Using
python >= 3.7
Development and Examples
sphinx
plotly
numpy
panda
python-kaleido
Credits
This code originated from a post by Adam Urbanczyk to the CadQuery forum and this package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2020-08-31)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
taperable_helix-0.7.0.tar.gz
(18.2 kB
view hashes)
Built Distribution
Close
Hashes for taperable_helix-0.7.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 149eb63b01715a765052b2d7da817278667427ee7fa8b760c1fed8db93c12501 |
|
MD5 | be0ce4a0a219291fdc78b5ada91ea002 |
|
BLAKE2b-256 | f9c88da164caa34e3a5259f2bdc48ed436da5333190e2a071ae0714e45f0c723 |