Last active
August 29, 2015 14:17
-
-
Save jayeye/3a3d7c984b962ba8c7f3 to your computer and use it in GitHub Desktop.
Convert filament length to filament weight and vice versa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLA = 1.24 | |
ABS = 1.03 | |
def _normalize_density(d): | |
"""Density can be specified as g/cm^3 (common way) or kg/m^3 (SI way). | |
Assumes we are not dealing with degenerate matter! | |
""" | |
return (d < 25) and (d * 1000) or d | |
def l2w(length, diameter=2.85, density=PLA): | |
"""length in meters to weight in kilograms.""" | |
return length * (.785e-6 * diameter * diameter * _normalize_density(density)) | |
def w2l(weight, diameter=2.85, density=PLA): | |
"""weight in kilograms to length in meters.""" | |
return weight / (.785e-6 * diameter * diameter * _normalize_density(density)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment