or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/numpy-stl@3.2.x
tile.json

tessl/pypi-numpy-stl

tessl install tessl/pypi-numpy-stl@3.2.0

Library to make reading, writing and modifying both binary and ascii STL files easy.

Agent Success

Agent success rate when using this tile

85%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.39x

Baseline

Agent success rate without this tile

61%

task.mdevals/scenario-6/

STL Mass Reporter

A utility that loads an STL mesh and reports its volume, center of gravity, inertia tensor, and mass, scaling results when a material density is provided.

Capabilities

Compute volume and center

  • For the provided unit cube STL fixture at fixtures/unit_cube_ascii.stl, returns a positive volume near 1.0 and a center of gravity near (0.5, 0.5, 0.5) when using default unit density. @test

Derive inertia tensor about origin

  • Produces a 3x3 inertia tensor about the origin axes for the same cube, yielding symmetric rows and diagonal terms near 0.1667 under unit density. @test

Apply density scaling

  • When a density override (e.g., 2.7) is supplied, scales mass and every inertia tensor term proportionally while leaving the geometric center unchanged. @test

Accept ASCII or binary STL input

  • Handles both ASCII and binary STL representations of the cube fixture at fixtures/unit_cube_ascii.stl and fixtures/unit_cube_binary.stl without changing computed properties beyond minor floating-point noise. @test

Implementation

@generates

API

from typing import Iterable, Mapping, Tuple


def summarize_mass_properties(stl_path: str, density: float | None = None) -> Mapping[str, object]:
    """
    Load an STL mesh from the given path and compute mass properties derived from its triangles.

    Returns a mapping containing:
    - 'volume': float (always positive)
    - 'mass': float (equals volume when density is None)
    - 'center_of_gravity': Tuple[float, float, float]
    - 'inertia_tensor': Iterable[Iterable[float]] (3x3, row-major, symmetric)

    When density is provided, scale mass and the inertia tensor by that density while keeping the center fixed.
    Calculations must come from the mesh geometry rather than hardcoded constants.
    """


def format_report(properties: Mapping[str, object]) -> str:
    """
    Produce a multi-line summary string that includes volume, mass, center of gravity, and each row of the inertia tensor.
    Values should be formatted with reasonable precision suitable for textual comparison in tests.
    """

Dependencies { .dependencies }

numpy-stl { .dependency }

Triangular mesh loading and mass/inertia computation.