mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-08-01 02:10:38 +02:00
Fixed vnf_get_vertex() for single point.
This commit is contained in:
@@ -36,8 +36,9 @@ test_vnf_faces();
|
|||||||
|
|
||||||
module test_vnf_get_vertex() {
|
module test_vnf_get_vertex() {
|
||||||
vnf = [[[-1,-1,-1],[1,-1,-1],[0,1,-1],[0,0,1]],[[0,1,2],[0,3,1],[1,3,2],[2,3,0]]];
|
vnf = [[[-1,-1,-1],[1,-1,-1],[0,1,-1],[0,0,1]],[[0,1,2],[0,3,1],[1,3,2],[2,3,0]]];
|
||||||
assert(vnf_get_vertex(vnf,[0,1,-1]) == [[2],vnf]);
|
assert(vnf_get_vertex(vnf,[0,1,-1]) == [2,vnf]);
|
||||||
assert(vnf_get_vertex(vnf,[0,1,2]) == [[4],[concat(vnf[0],[[0,1,2]]),vnf[1]]]);
|
assert(vnf_get_vertex(vnf,[0,1,2]) == [4,[concat(vnf[0],[[0,1,2]]),vnf[1]]]);
|
||||||
|
assert(vnf_get_vertex(vnf,[[0,1,-1],[0,1,2]]) == [[2,4],[concat(vnf[0],[[0,1,2]]),vnf[1]]]);
|
||||||
}
|
}
|
||||||
test_vnf_get_vertex();
|
test_vnf_get_vertex();
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,525];
|
BOSL_VERSION = [2,0,526];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
20
vnf.scad
20
vnf.scad
@@ -66,10 +66,11 @@ function vnf_quantize(vnf,q=pow(2,-12)) =
|
|||||||
// Usage:
|
// Usage:
|
||||||
// vvnf = vnf_get_vertex(vnf, p);
|
// vvnf = vnf_get_vertex(vnf, p);
|
||||||
// Description:
|
// Description:
|
||||||
// Finds the index number of the given vertex point `p` in the given VNF structure `vnf`. If said
|
// Finds the index number of the given vertex point `p` in the given VNF structure `vnf`.
|
||||||
// point does not already exist in the VNF vertex list, it is added. Returns: `[INDEX, VNF]` where
|
// If said point does not already exist in the VNF vertex list, it is added to the returned VNF.
|
||||||
// INDEX if the index of the point, and VNF is the possibly modified new VNF structure.
|
// Returns: `[INDEX, VNF]` where INDEX is the index of the point in the returned VNF's vertex list,
|
||||||
// If `p` is given as a list of points, then INDEX will be a list of indices.
|
// and VNF is the possibly modified new VNF structure. If `p` is given as a list of points, then
|
||||||
|
// the returned INDEX will be a list of indices.
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// vnf = The VNF structue to get the point index from.
|
// vnf = The VNF structue to get the point index from.
|
||||||
// p = The point, or list of points to get the index of.
|
// p = The point, or list of points to get the index of.
|
||||||
@@ -80,10 +81,13 @@ function vnf_quantize(vnf,q=pow(2,-12)) =
|
|||||||
// vnf4 = vnf_get_vertex(vnf3, p=[[1,3,2],[3,2,1]]); // Returns: [[1,2], [[[3,5,8],[3,2,1],[1,3,2]],[]]]
|
// vnf4 = vnf_get_vertex(vnf3, p=[[1,3,2],[3,2,1]]); // Returns: [[1,2], [[[3,5,8],[3,2,1],[1,3,2]],[]]]
|
||||||
function vnf_get_vertex(vnf=EMPTY_VNF, p) =
|
function vnf_get_vertex(vnf=EMPTY_VNF, p) =
|
||||||
let(
|
let(
|
||||||
p = is_vector(p)? [p] : p,
|
isvec = is_vector(p),
|
||||||
res = set_union(vnf[0], p, get_indices=true)
|
pts = isvec? [p] : p,
|
||||||
)
|
res = set_union(vnf[0], pts, get_indices=true)
|
||||||
[res[0], [res[1],vnf[1]]];
|
) [
|
||||||
|
(isvec? res[0][0] : res[0]),
|
||||||
|
[ res[1], vnf[1] ]
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
// Function: vnf_add_face()
|
// Function: vnf_add_face()
|
||||||
|
Reference in New Issue
Block a user