Library to make reading, writing and modifying both binary and ascii STL files easy.
85
Evaluation — 85%
↑ 1.39xAgent success when using this tile
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.
Install with Tessl CLI
npx tessl i tessl/pypi-numpy-stlevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10