Skip to main content

Creates a helical thread

Project description

Create helical threads

Examples

def add_traces(
    name: str,
    fig: go.Figure,
    ths: ThreadHelixes,
    helix_locations: List[HelixLocation],
    vert_offset: float = 0,
) -> None:

    # Loop over each of the helexis adding a trace for each
    for i, hl in enumerate(helix_locations):
        # Create the helix funtion
        f = ths.ht.helix(hl)

        # Create a list of points using map to invoke "f"
        # over 500 points between first_t and last_t inclusive.
        points = list(
            map(f, linspace(ths.ht.first_t, ths.ht.last_t, num=500, dtype=float))
        )

        # Check if we should offset the points
        if vert_offset != 0:
            points = [(x, y, z + vert_offset) for x, y, z in points]

        # Add a trace decomposing points into three separate lists
        fig.add_trace(
            go.Scatter3d(
                # Extract x, y, z
                x=[x for x, _, _ in points],
                y=[y for _, y, _ in points],
                z=[z for _, _, z in points],
                mode="lines",
                name=f"{name}{i}",
            )
        )


if __name__ == "__main__":
    params = Parameters(argv[1:])
    ths: ThreadHelixes = helical_thread(params.ht)

    # Create a plotly figure
    fig = go.Figure(
        # layout_title_text="Helical Triangle",
        layout_scene_camera_projection_type="orthographic",
    )

    # Add the traces for internal/external or both

    if (params.int_ext_both == "int") or (params.int_ext_both == "both"):
        add_traces("int", fig, ths, ths.int_helixes)

    if (params.int_ext_both == "ext") or (params.int_ext_both == "both"):
        # When doing set the vert_offset to pitch / s so we see the thread alignment
        vert_offset = ths.ht.pitch / 2 if params.int_ext_both == "both" else 0
        add_traces("ext", fig, ths, ths.ext_helixes, vert_offset)

    # Show the figure
    fig.show()

    if params.write:
        # Write the image is requested
        try:
            fname = "data/int_ext_both.webp"
            fig.write_image(fname)
            print(f"wrote: {fname}")
        except Exception as e:
            print(f"Unable to write files; maybe run from project root: e={e}")
https://raw.githubusercontent.com/winksaville/py-helical-thread/main/data/int_ext_both.webp

Prerequisites

Using

  • python >= 3.7

Development and Examples

See dev-requirements.in for most up to date list:

  • pip-tools

  • bump2version

  • wheel

  • isort

  • black

  • flake8

  • tox

  • tox-conda

  • coverage

  • Sphinx>=3.2

  • sphinx_rtd_theme

  • sphinx-autodoc-typehints

  • sphinx-prompt

  • sphinx_substitution_extensions>=2020.09.30, <2021.12.00

  • taperable-helix

  • twine

  • pytest

  • pytest-runner

  • kaleido

  • plotly

  • psutil

  • numpy

  • pandas

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

helical_thread-0.2.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

helical_thread-0.2.2-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file helical_thread-0.2.2.tar.gz.

File metadata

  • Download URL: helical_thread-0.2.2.tar.gz
  • Upload date:
  • Size: 5.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/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.8

File hashes

Hashes for helical_thread-0.2.2.tar.gz
Algorithm Hash digest
SHA256 32e9276e71eb853662f5f067c7b8d9a61dbbf8a3064ac97dc5ee9296ec873a6d
MD5 9d070ebc7112c9aba58961f0369d883b
BLAKE2b-256 d5ddd71faf3984b9353b9414bd33b05c0f22cd8d965b2d661f1c16d6fbcfbc95

See more details on using hashes here.

File details

Details for the file helical_thread-0.2.2-py2.py3-none-any.whl.

File metadata

  • Download URL: helical_thread-0.2.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.4 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/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.8

File hashes

Hashes for helical_thread-0.2.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d3f76fd9991dfbab88c8fb130e599b5ad980b89c18b372482592baad3ce0fa67
MD5 b0754f4e0706967b2a447c01ce5fdde3
BLAKE2b-256 6c44e3fd311d1b569dd7ef7bd4d60045e722db03d48da2bf771f8fd2f99bebaf

See more details on using hashes here.

Supported by

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