Skip to main content

Generate helixes that can optionally taper to a point at each end.

Project description

Taperable Helix

Documentation Status

Generate helixes that can optionally taper to a point at each end.

Package Docs

@dataclass
class HelixLocation:
    radius: Optional[float] = None  #: radius of helix if none h.radius
    horz_offset: float = 0  #: horizontal offset  added to radius then x and y calculated
    vert_offset: float = 0  #: vertical added to z of radius


@dataclass
class Helix:
    """This class represents a taperable Helix.

    The required attributes are radius,
    pitch and height. Thse attributes create simple single line helix.
    But the primary purpose for Helix is to create a set of helical "wires"
    using non-zero values for taper_rpos, horz_offset and vert_offset to
    define solid helixes that can taper at each end to a point.

    This is useful for creating internal and external threads for nuts and
    bolts.  This is accomplished by invoking helix() multiple times with
    same radius, pitch, taper_rpos, inset_offset, first_t, and last_t.
    But with different HelixLocation radius, horz_offset and vert_offset.

    Each returned function will then generate a helix defining an edge
    of the thread. The edges can be used to make faces and subsequently
    a solid of the thread. This can then be combined with the "core" objects
    which the threads are "attached" using a "union" operator.
    """

    radius: float #: radius of the basic helix.

    pitch: float
    """pitch of the helix per revolution. I.e the distance between the
    height of a single "turn" of the helix.
    """

    height: float  #: height of the cyclinder containing the helix.

    taper_out_rpos: float = 0
    """taper_out_rpos is a decimal number with an inclusive range of 0..1
    such that (taper_out_rpos * t_range) defines the t value where tapering
    out ends, it begins at t == first_t.  A ValueError exception is raised
    if taper_out_rpos < 0 or > 1 or taper_out_rpos > taper_in_rpos.
    Default is 0 which is no out taper.
    """

    taper_in_rpos: float = 1
    """taper_in_rpos: is a decimal number with an inclusive range of 0..1
    such that (taper_in_rpos * t_range) defines the t value where tapering
    in begins, it ends at t == last_t.  A ValueError exception is raised
    if taper_out_rpos < 0 or > 1 or taper_out_rpos > taper_in_rpos.
    Default is 1 which is no in taper.
    """

    inset_offset: float = 0
    """inset_offset: the helix will start at z = inset_offset and will
    end at z = height - (2 * inset_offset). Default 0.
    """

    first_t: float = 0  #: first_t is the first t value passed to the returned function. Default 0

    last_t: float = 1 #: last_t is the last t value passed to the returned function. Default 1


    def helix(
        self, 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 = h.helix()
    points = list(map(f, linspace(start=0, stop=1, num=num_points, dtype=float)))
    # print(f"helical_line: points={points}")
    return points
https://raw.githubusercontent.com/winksaville/py-taperable-helix/master/data/helical_line.webp
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 = h.helix(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 = h.helix(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 = h.helix(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)
https://raw.githubusercontent.com/winksaville/py-taperable-helix/master/data/helical_tri.webp

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


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.8.5.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

taperable_helix-0.8.5-py2.py3-none-any.whl (8.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file taperable_helix-0.8.5.tar.gz.

File metadata

  • Download URL: taperable_helix-0.8.5.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for taperable_helix-0.8.5.tar.gz
Algorithm Hash digest
SHA256 a3b7a8deeb5f1cd3cb23a42567fe85fe249595a372fb43925c06af061249adf2
MD5 faade2fbe4784d7f6490e51bab642f0d
BLAKE2b-256 51bb94fa5041179217cec4ba7cda0fa0ef9e54bc2fb49fee02b0ac88da94d442

See more details on using hashes here.

File details

Details for the file taperable_helix-0.8.5-py2.py3-none-any.whl.

File metadata

  • Download URL: taperable_helix-0.8.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for taperable_helix-0.8.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d4781740e596a320981ec325afbcca23f26d52b8718f1523921697ea3ad3f8e4
MD5 da695b7ca3fbbb61d7074bfacec8854d
BLAKE2b-256 a73c2d153bdae7dfac0cf763f771ddf2bbae724c8594acec49b036f977fb33c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page