mirror of
https://github.com/nophead/NopSCADlib.git
synced 2025-08-09 17:06:34 +02:00
Added layer_height0 global variable and updated round_to_layer() to handle it.
Moved functions from global_defs.scad to global.scad so they get documented.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
//
|
||||
//! Global constants, functions and modules. This file is used directly or indirectly in every scad file.
|
||||
//! See [global_defs.scad](../../global_defs.scad) for a list of global constants.
|
||||
//
|
||||
include <../../global_defs.scad>
|
||||
|
||||
@@ -38,6 +39,13 @@ function r2sides(r) = $fn ? $fn : ceil(max(min(360/ $fa, r * 2 * PI / $fs), 5));
|
||||
function r2sides4n(r) = floor((r2sides(r) + 3) / 4) * 4; //! Round up the number of sides to a multiple of 4 to ensure points land on all axes
|
||||
function limit(x, min, max) = max(min(x, max), min); //! Force x in range min <= x <= max
|
||||
|
||||
function round_to_layer(z) = //! Round up to a layer boundary using `layer_height0` for the first layer and `layer_height` for subsequent layers.
|
||||
z <= 0 ? 0 :
|
||||
z <= layer_height0 ? layer_height0 :
|
||||
ceil((z -layer_height0) / layer_height) * layer_height + layer_height0;
|
||||
|
||||
function grey(n) = [0.01, 0.01, 0.01] * n; //! Generate a shade of grey to pass to color().
|
||||
|
||||
module translate_z(z) //! Shortcut for Z only translations
|
||||
translate([0, 0, z]) children();
|
||||
|
||||
|
Reference in New Issue
Block a user