mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Fix coords.scad regressions.
This commit is contained in:
parent
6de4efabe4
commit
19e6ec8093
3 changed files with 26 additions and 19 deletions
28
coords.scad
28
coords.scad
|
@ -30,10 +30,10 @@ function point2d(p, fill=0) = [for (i=[0:1]) (p[i]==undef)? fill : p[i]];
|
|||
// points = A list of 2D or 3D points/vectors.
|
||||
// fill = Value to fill missing values in vectors with.
|
||||
function path2d(points) =
|
||||
assert(is_path(points,dim=undef,fast=true),"Input to path2d is not a path")
|
||||
let (result = points * concat(ident(2), replist([0,0], len(points[0])-2)))
|
||||
assert(is_def(result), "Invalid input to path2d")
|
||||
result;
|
||||
assert(is_path(points,dim=undef,fast=true),"Input to path2d is not a path")
|
||||
let (result = points * concat(ident(2), replist([0,0], len(points[0])-2)))
|
||||
assert(is_def(result), "Invalid input to path2d")
|
||||
result;
|
||||
|
||||
|
||||
// Function: point3d()
|
||||
|
@ -53,16 +53,16 @@ function point3d(p, fill=0) = [for (i=[0:2]) (p[i]==undef)? fill : p[i]];
|
|||
// points = A list of 2D, 3D or higher dimensional points/vectors.
|
||||
// fill = Value to fill missing values in vectors with (in the 2D case)
|
||||
function path3d(points, fill=0) =
|
||||
assert(is_num(fill))
|
||||
assert(is_path(points, dim=undef, fast=true), "Input to path3d is not a path")
|
||||
let (
|
||||
change = len(points[0])-3,
|
||||
M = change < 0 ? [[1,0,0],[0,1,0]] :
|
||||
concat(ident(3), replist([0,0,0],change)),
|
||||
result = points*M
|
||||
)
|
||||
assert(is_def(result), "Input to path3d is invalid")
|
||||
fill == 0 || change>=0 ? result : result + replist([0,0,fill], len(result));
|
||||
assert(is_num(fill))
|
||||
assert(is_path(points, dim=undef, fast=true), "Input to path3d is not a path")
|
||||
let (
|
||||
change = len(points[0])-3,
|
||||
M = change < 0? [[1,0,0],[0,1,0]] :
|
||||
concat(ident(3), replist([0,0,0],change)),
|
||||
result = points*M
|
||||
)
|
||||
assert(is_def(result), "Input to path3d is invalid")
|
||||
fill == 0 || change>=0 ? result : result + replist([0,0,fill], len(result));
|
||||
|
||||
|
||||
// Function: point4d()
|
||||
|
|
|
@ -10,7 +10,9 @@ test_point2d();
|
|||
|
||||
|
||||
module test_path2d() {
|
||||
assert(path2d([[1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5]])==[[1,0],[1,2],[1,2],[1,2],[1,2]]);
|
||||
assert(path2d([[1,2], [3,4], [5,6], [7,8]])==[[1,2],[3,4],[5,6],[7,8]]);
|
||||
assert(path2d([[1,2,3], [2,3,4], [3,4,5], [4,5,6]])==[[1,2],[2,3],[3,4],[4,5]]);
|
||||
assert(path2d([[1,2,3,4], [2,3,4,5], [3,4,5,6], [4,5,6,7]])==[[1,2],[2,3],[3,4],[4,5]]);
|
||||
}
|
||||
test_path2d();
|
||||
|
||||
|
@ -26,7 +28,9 @@ test_point3d();
|
|||
|
||||
|
||||
module test_path3d() {
|
||||
assert(path3d([[1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5]])==[[1,0,0],[1,2,0],[1,2,3],[1,2,3],[1,2,3]]);
|
||||
assert(path3d([[1,2], [3,4], [5,6], [7,8]])==[[1,2,0],[3,4,0],[5,6,0],[7,8,0]]);
|
||||
assert(path3d([[1,2,3], [2,3,4], [3,4,5], [4,5,6]])==[[1,2,3],[2,3,4],[3,4,5],[4,5,6]]);
|
||||
assert(path3d([[1,2,3,4], [2,3,4,5], [3,4,5,6], [4,5,6,7]])==[[1,2,3],[2,3,4],[3,4,5],[4,5,6]]);
|
||||
}
|
||||
test_path3d();
|
||||
|
||||
|
@ -42,7 +46,10 @@ test_point4d();
|
|||
|
||||
|
||||
module test_path4d() {
|
||||
assert(path4d([[1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5]])==[[1,0,0,0],[1,2,0,0],[1,2,3,0],[1,2,3,4],[1,2,3,4]]);
|
||||
assert(path4d([[1,2], [3,4], [5,6], [7,8]])==[[1,2,0,0],[3,4,0,0],[5,6,0,0],[7,8,0,0]]);
|
||||
assert(path4d([[1,2,3], [2,3,4], [3,4,5], [4,5,6]])==[[1,2,3,0],[2,3,4,0],[3,4,5,0],[4,5,6,0]]);
|
||||
assert(path4d([[1,2,3,4], [2,3,4,5], [3,4,5,6], [4,5,6,7]])==[[1,2,3,4],[2,3,4,5],[3,4,5,6],[4,5,6,7]]);
|
||||
assert(path4d([[1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7], [4,5,6,7,8]])==[[1,2,3,4],[2,3,4,5],[3,4,5,6],[4,5,6,7]]);
|
||||
}
|
||||
test_path4d();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,149];
|
||||
BOSL_VERSION = [2,0,150];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue