minor doc fixes and bugfix for closed path tangents with path_sweep

This commit is contained in:
Adrian Mariano 2020-10-05 17:40:32 -04:00
parent dbcc334087
commit c71112347e
2 changed files with 5 additions and 6 deletions

View file

@ -472,7 +472,7 @@ function _normal_segment(p1,p2) =
// Function: turtle() // Function: turtle()
// Usage: // Usage:
// turtle(commands, [state], [return_state]) // turtle(commands, [state], [full_state], [repeat])
// Description: // Description:
// Use a sequence of turtle graphics commands to generate a path. The parameter `commands` is a list of // Use a sequence of turtle graphics commands to generate a path. The parameter `commands` is a list of
// turtle commands and optional parameters for each command. The turtle state has a position, movement direction, // turtle commands and optional parameters for each command. The turtle state has a position, movement direction,
@ -481,9 +481,8 @@ function _normal_segment(p1,p2) =
// the computed turtle path. If you set `full_state` to true then it instead returns the full turtle state. // the computed turtle path. If you set `full_state` to true then it instead returns the full turtle state.
// You can invoke `turtle` again with this full state to continue the turtle path where you left off. // You can invoke `turtle` again with this full state to continue the turtle path where you left off.
// . // .
// The turtle state is a list with three entries: the path constructed so far, the current step as a 2-vector, and the current default angle. // The turtle state is a list with three entries: the path constructed so far, the current step as a 2-vector, the current default angle,
// . // and the current arcsteps setting.
// For the list below, `dist` is the current movement distance.
// . // .
// Commands | Arguments | What it does // Commands | Arguments | What it does
// ------------ | ------------------ | ------------------------------- // ------------ | ------------------ | -------------------------------
@ -613,7 +612,7 @@ function _turtle(commands, state, full_state, index=0) =
) : ) :
( full_state ? state : state[0] ); ( full_state ? state : state[0] );
// Turtle state: state = [path, step_vector, default angle] // Turtle state: state = [path, step_vector, default angle, default arcsteps]
function _turtle_command(command, parm, parm2, state, index) = function _turtle_command(command, parm, parm2, state, index) =
command == "repeat"? command == "repeat"?

View file

@ -1184,7 +1184,7 @@ function path_sweep(shape, path, method="incremental", normal, closed=false, twi
assert(is_undef(normal) || (is_vector(normal) && len(normal)==3) || (is_path(normal) && len(normal)==len(path) && len(normal[0])==3), "Invalid normal specified") assert(is_undef(normal) || (is_vector(normal) && len(normal)==3) || (is_path(normal) && len(normal)==len(path) && len(normal[0])==3), "Invalid normal specified")
assert(is_undef(tangent) || (is_path(tangent) && len(tangent)==len(path) && len(tangent[0])==3), "Invalid tangent specified") assert(is_undef(tangent) || (is_path(tangent) && len(tangent)==len(path) && len(tangent[0])==3), "Invalid tangent specified")
let( let(
tangents = is_undef(tangent) ? path_tangents(path) : [for(t=tangent) unit(t)], tangents = is_undef(tangent) ? path_tangents(path,closed=closed) : [for(t=tangent) unit(t)],
normal = is_path(normal) ? [for(n=normal) unit(n)] : normal = is_path(normal) ? [for(n=normal) unit(n)] :
is_def(normal) ? unit(normal) : is_def(normal) ? unit(normal) :
method =="incremental" && abs(tangents[0].z) > 1/sqrt(2) ? BACK : UP, method =="incremental" && abs(tangents[0].z) > 1/sqrt(2) ? BACK : UP,