tessl install tessl/pypi-numpy-stl@3.2.0Library 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%
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.
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. @testfixtures/unit_cube_ascii.stl and fixtures/unit_cube_binary.stl without changing computed properties beyond minor floating-point noise. @test@generates
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.
"""Triangular mesh loading and mass/inertia computation.