Files
spoolman2/spoolman/math.py
Donkie 6fd9662c42 Renamed to Spoolman
Spoolson just didn't sound that good after all
2023-04-02 19:19:15 +02:00

20 lines
521 B
Python

"""Various math-related functions."""
import math
def weight_from_length(*, length: float, radius: float, density: float) -> float:
"""Calculate the weight of a piece of filament.
Args:
length (float): Filament length in mm
radius (float): Filament radius in mm
density (float): Density of filament material in g/cm3
Returns:
float: Weight in g
"""
volume_mm3 = length * math.pi * radius * radius
volume_cm3 = volume_mm3 / 1000
return density * volume_cm3