From 957907200b7e4eaea8353cd0a7b4a3db1a28ff6e Mon Sep 17 00:00:00 2001 From: Adrian Mariano Date: Fri, 2 Apr 2021 20:39:14 -0400 Subject: [PATCH] bezier doc fixes, test for complex() --- beziers.scad | 15 ++++++++------- tests/test_math.scad | 9 +++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/beziers.scad b/beziers.scad index 721d8cf..79ecac8 100644 --- a/beziers.scad +++ b/beziers.scad @@ -413,16 +413,17 @@ function bezier_curvature(curve, u) = // Topics: Bezier Segments // See Also: bezier_curvature(), bezier_tangent(), bezier_derivative(), bezier_points() // Description: -// Takes a list of bezier curve control points and generates n points along the bezier path. -// Points start at the first control point and are sampled every `1/n`th -// of the way along the bezier parameter, ending *before* the final control point by default. -// The distance between the points will *not* be equidistant. If you wish to add the -// endpoint you can set `endpoint` to true. The degree of the bezier curve is one -// less than the number of points in `curve`. +// Takes a list of bezier control points and generates n points along the bezier curve they define. +// Points start at the first control point and are sampled uniformly along the bezier parameter. +// The endpoints of the output will be *exactly* equal to the first and last bezier control points +// when endpoint is true. If endpoint is false the sampling stops one step before the final point +// of the bezier curve, but you still get n, more tightly spaced, points. +// The distance between the points will *not* be equidistant. +// The degree of the bezier curve is one less than the number of points in `curve`. // Arguments: // curve = The list of endpoints and control points for this bezier segment. // n = The number of points to generate along the bezier curve. -// endpoint = if true then add the endpoint (an extra point, giving n+1 points output). Default: False +// endpoint = if false then exclude the endpoint. Default: True // Example(2D): Quadratic (Degree 2) Bezier. // bez = [[0,0], [30,30], [80,0]]; // move_copies(bezier_curve(bez, 8)) sphere(r=1.5, $fn=12); diff --git a/tests/test_math.scad b/tests/test_math.scad index e943756..35098a1 100644 --- a/tests/test_math.scad +++ b/tests/test_math.scad @@ -830,6 +830,15 @@ module test_lcm() { test_lcm(); + +module test_complex(){ + assert_equal( complex(ident(4)), c_ident(4)); + assert_equal( complex(3), [3,0]); + assert_equal( complex([1,2]), [[1,0],[2,0]]); + assert_equal( complex([[1,2],[3,4]]), [[ [1,0],[2,0] ], [ [3,0],[4,0]]]); +} +test_complex(); + module test_c_mul() { assert_equal(c_mul([4,5],[9,-4]), [56,29]); assert_equal(c_mul([-7,2],[24,3]), [-174, 27]);