mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added more edge set figures.
This commit is contained in:
parent
6904aedba3
commit
a8db3919c1
2 changed files with 84 additions and 85 deletions
167
edges.scad
167
edges.scad
|
@ -8,6 +8,33 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// CommonCode:
|
||||
// module text3d(txt,size=3) {
|
||||
// if (is_list(txt)) {
|
||||
// for (i=idx(txt)) {
|
||||
// down((i-len(txt)/2+1)*size*1.25) {
|
||||
// text3d(txt[i], size=size);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// xrot(90) color("#000")
|
||||
// linear_extrude(height=0.1) {
|
||||
// text(text=txt, size=size, halign="center", valign="center");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// module edge_cube(size=20, chamfer=3, txtsize=3, edges="ALL") {
|
||||
// lbl = is_string(edges)? [str("\"",edges,"\"")] : concat(
|
||||
// edges.z>0? ["TOP"] : edges.z<0? ["BTM"] : [],
|
||||
// edges.y>0? ["BACK"] : edges.y<0? ["FWD"] : [],
|
||||
// edges.x>0? ["RIGHT"] : edges.x<0? ["LEFT"] : []
|
||||
// );
|
||||
// lbl2 = [for (i=idx(lbl)) i<len(lbl)-1? str(lbl[i],"+") : lbl[i]];
|
||||
// cuboid(size=size,chamfer=chamfer,edges=edges);
|
||||
// fwd(size/2) text3d(lbl2, size=txtsize);
|
||||
// }
|
||||
|
||||
|
||||
// Section: Sets of Edges
|
||||
// Constants for specifying edges for `cuboid()`, etc.
|
||||
|
||||
|
@ -25,30 +52,7 @@ EDGES_ALL = [[1,1,1,1], [1,1,1,1], [1,1,1,1]]; // All edges.
|
|||
function is_edge_array(v) = is_list(v) && is_vector(v[0]) && len(v)==3 && len(v[0])==4;
|
||||
|
||||
|
||||
// Function: edge_set()
|
||||
// Usage:
|
||||
// edge_set(v);
|
||||
// Description:
|
||||
// Takes an edge set descriptor and returns the edges array representing those edges.
|
||||
// This function is useful for modules that take `edges` arguments, like `cuboid()`.
|
||||
// An edge set descriptor can be any of:
|
||||
// - A vector pointing towards an edge, indicating just that edge.
|
||||
// - A vector pointing towards a face, indicating all edges surrounding that face.
|
||||
// - A vector pointing towards a corner, indicating all edges that meet at that corner.
|
||||
// - The string `"X"`, indicating all X axis aligned edges.
|
||||
// - The string `"Y"`, indicating all Y axis aligned edges.
|
||||
// - The string `"Z"`, indicating all Z axis aligned edges.
|
||||
// - The string `"ALL"`, indicating all edges.
|
||||
// - The string `"NONE"`, indicating no edges at all.
|
||||
// - A raw edges array, where each edge is represented by a 1 or a 0. The edge ordering is:
|
||||
// ```
|
||||
// [
|
||||
// [Y-Z-, Y+Z-, Y-Z+, Y+Z+],
|
||||
// [X-Z-, X+Z-, X-Z+, X+Z+],
|
||||
// [X-Y-, X+Y-, X-Y+, X+Y+]
|
||||
// ]
|
||||
// ```
|
||||
function edge_set(v) =
|
||||
function _edge_set(v) =
|
||||
is_edge_array(v)? v : [
|
||||
for (ax=[0:2]) [
|
||||
for (b=[-1,1], a=[-1,1]) let(
|
||||
|
@ -116,70 +120,65 @@ function normalize_edges(v) = [for (ax=v) [for (edge=ax) edge>0? 1 : 0]];
|
|||
// [X-Y-, X+Y-, X-Y+, X+Y+]
|
||||
// ]
|
||||
// ```
|
||||
// Figure(3DBig): Face Vector Edge Sets
|
||||
// module text3d(txt) {
|
||||
// xrot(90)
|
||||
// color("#000")
|
||||
// linear_extrude(height=0.1) {
|
||||
// text(text=txt, size=3, halign="center", valign="center");
|
||||
// }
|
||||
// }
|
||||
// Figure(3DBig): Edge Vectors
|
||||
// ydistribute(50) {
|
||||
// ydistribute(10) {
|
||||
// xdistribute(30) {
|
||||
// text3d("LEFT");
|
||||
// text3d("FRONT");
|
||||
// text3d("RIGHT");
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// cuboid(20,chamfer=3,edges=LEFT);
|
||||
// cuboid(20,chamfer=3,edges=FRONT);
|
||||
// cuboid(20,chamfer=3,edges=RIGHT);
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=BOT+RIGHT);
|
||||
// edge_cube(edges=BOT+BACK);
|
||||
// edge_cube(edges=BOT+LEFT);
|
||||
// edge_cube(edges=BOT+FRONT);
|
||||
// }
|
||||
// ydistribute(10) {
|
||||
// xdistribute(30) {
|
||||
// text3d("TOP");
|
||||
// text3d("BACK");
|
||||
// text3d("BOTTOM");
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// cuboid(20,chamfer=3,edges=TOP);
|
||||
// cuboid(20,chamfer=3,edges=BACK);
|
||||
// cuboid(20,chamfer=3,edges=BOTTOM);
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=FWD+RIGHT);
|
||||
// edge_cube(edges=BACK+RIGHT);
|
||||
// edge_cube(edges=BACK+LEFT);
|
||||
// edge_cube(edges=FWD+LEFT);
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=TOP+RIGHT);
|
||||
// edge_cube(edges=TOP+BACK);
|
||||
// edge_cube(edges=TOP+LEFT);
|
||||
// edge_cube(edges=TOP+FRONT);
|
||||
// }
|
||||
// }
|
||||
// Figure(3DBig): Named Edge Sets
|
||||
// module text3d(txt) {
|
||||
// xrot(90)
|
||||
// color("#000")
|
||||
// linear_extrude(height=0.1) {
|
||||
// text(text=txt, size=3.5, halign="center", valign="center");
|
||||
// Figure(3DBig): Corner Vector Edge Sets
|
||||
// ydistribute(50) {
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=FRONT+LEFT+TOP);
|
||||
// edge_cube(edges=FRONT+RIGHT+TOP);
|
||||
// edge_cube(edges=FRONT+LEFT+BOT);
|
||||
// edge_cube(edges=FRONT+RIGHT+BOT);
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=TOP+LEFT+BACK);
|
||||
// edge_cube(edges=TOP+RIGHT+BACK);
|
||||
// edge_cube(edges=BOT+LEFT+BACK);
|
||||
// edge_cube(edges=BOT+RIGHT+BACK);
|
||||
// }
|
||||
// }
|
||||
// ydistribute(75) {
|
||||
// ydistribute(10) {
|
||||
// xdistribute(30) {
|
||||
// text3d("\"X\"");
|
||||
// text3d("\"Y\"");
|
||||
// text3d("\"Z\"");
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// cuboid(20,chamfer=3,edges="X");
|
||||
// cuboid(20,chamfer=3,edges="Y");
|
||||
// cuboid(20,chamfer=3,edges="Z");
|
||||
// }
|
||||
// Figure(3D): Face Vector Edge Sets
|
||||
// ydistribute(50) {
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=LEFT);
|
||||
// edge_cube(edges=FRONT);
|
||||
// edge_cube(edges=RIGHT);
|
||||
// }
|
||||
// ydistribute(10) {
|
||||
// xdistribute(30) {
|
||||
// text3d("\"ALL\"");
|
||||
// text3d("\"NONE\"");
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// cuboid(20,chamfer=3,edges="ALL");
|
||||
// cuboid(20,chamfer=3,edges="NONE");
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges=TOP);
|
||||
// edge_cube(edges=BACK);
|
||||
// edge_cube(edges=BOTTOM);
|
||||
// }
|
||||
// }
|
||||
// Figure(3D): Named Edge Sets
|
||||
// ydistribute(50) {
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges="X");
|
||||
// edge_cube(edges="Y");
|
||||
// edge_cube(edges="Z");
|
||||
// }
|
||||
// xdistribute(30) {
|
||||
// edge_cube(edges="ALL");
|
||||
// edge_cube(edges="NONE");
|
||||
// }
|
||||
// }
|
||||
// Example: Just the front-top edge
|
||||
|
@ -199,10 +198,10 @@ function normalize_edges(v) = [for (ax=v) [for (edge=ax) edge>0? 1 : 0]];
|
|||
function edges(v, except=[]) =
|
||||
(is_string(v) || is_vector(v) || is_edge_array(v))? edges([v], except=except) :
|
||||
(is_string(except) || is_vector(except) || is_edge_array(except))? edges(v, except=[except]) :
|
||||
except==[]? normalize_edges(sum([for (x=v) edge_set(x)])) :
|
||||
except==[]? normalize_edges(sum([for (x=v) _edge_set(x)])) :
|
||||
normalize_edges(
|
||||
normalize_edges(sum([for (x=v) edge_set(x)])) -
|
||||
sum([for (x=except) edge_set(x)])
|
||||
normalize_edges(sum([for (x=v) _edge_set(x)])) -
|
||||
sum([for (x=except) _edge_set(x)])
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
BOSL_VERSION = [2,0,33];
|
||||
BOSL_VERSION = [2,0,34];
|
||||
|
||||
|
||||
// Section: BOSL Library Version Functions
|
||||
|
|
Loading…
Reference in a new issue