mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-03-09 02:39:47 +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
|
// Section: Sets of Edges
|
||||||
// Constants for specifying edges for `cuboid()`, etc.
|
// 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 is_edge_array(v) = is_list(v) && is_vector(v[0]) && len(v)==3 && len(v[0])==4;
|
||||||
|
|
||||||
|
|
||||||
// Function: edge_set()
|
function _edge_set(v) =
|
||||||
// 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) =
|
|
||||||
is_edge_array(v)? v : [
|
is_edge_array(v)? v : [
|
||||||
for (ax=[0:2]) [
|
for (ax=[0:2]) [
|
||||||
for (b=[-1,1], a=[-1,1]) let(
|
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+]
|
// [X-Y-, X+Y-, X-Y+, X+Y+]
|
||||||
// ]
|
// ]
|
||||||
// ```
|
// ```
|
||||||
// Figure(3DBig): Face Vector Edge Sets
|
// Figure(3DBig): Edge Vectors
|
||||||
// module text3d(txt) {
|
|
||||||
// xrot(90)
|
|
||||||
// color("#000")
|
|
||||||
// linear_extrude(height=0.1) {
|
|
||||||
// text(text=txt, size=3, halign="center", valign="center");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// ydistribute(50) {
|
// ydistribute(50) {
|
||||||
// ydistribute(10) {
|
// xdistribute(30) {
|
||||||
// xdistribute(30) {
|
// edge_cube(edges=BOT+RIGHT);
|
||||||
// text3d("LEFT");
|
// edge_cube(edges=BOT+BACK);
|
||||||
// text3d("FRONT");
|
// edge_cube(edges=BOT+LEFT);
|
||||||
// text3d("RIGHT");
|
// edge_cube(edges=BOT+FRONT);
|
||||||
// }
|
|
||||||
// xdistribute(30) {
|
|
||||||
// cuboid(20,chamfer=3,edges=LEFT);
|
|
||||||
// cuboid(20,chamfer=3,edges=FRONT);
|
|
||||||
// cuboid(20,chamfer=3,edges=RIGHT);
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// ydistribute(10) {
|
// xdistribute(30) {
|
||||||
// xdistribute(30) {
|
// edge_cube(edges=FWD+RIGHT);
|
||||||
// text3d("TOP");
|
// edge_cube(edges=BACK+RIGHT);
|
||||||
// text3d("BACK");
|
// edge_cube(edges=BACK+LEFT);
|
||||||
// text3d("BOTTOM");
|
// edge_cube(edges=FWD+LEFT);
|
||||||
// }
|
// }
|
||||||
// xdistribute(30) {
|
// xdistribute(30) {
|
||||||
// cuboid(20,chamfer=3,edges=TOP);
|
// edge_cube(edges=TOP+RIGHT);
|
||||||
// cuboid(20,chamfer=3,edges=BACK);
|
// edge_cube(edges=TOP+BACK);
|
||||||
// cuboid(20,chamfer=3,edges=BOTTOM);
|
// edge_cube(edges=TOP+LEFT);
|
||||||
// }
|
// edge_cube(edges=TOP+FRONT);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// Figure(3DBig): Named Edge Sets
|
// Figure(3DBig): Corner Vector Edge Sets
|
||||||
// module text3d(txt) {
|
// ydistribute(50) {
|
||||||
// xrot(90)
|
// xdistribute(30) {
|
||||||
// color("#000")
|
// edge_cube(edges=FRONT+LEFT+TOP);
|
||||||
// linear_extrude(height=0.1) {
|
// edge_cube(edges=FRONT+RIGHT+TOP);
|
||||||
// text(text=txt, size=3.5, halign="center", valign="center");
|
// 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) {
|
// Figure(3D): Face Vector Edge Sets
|
||||||
// ydistribute(10) {
|
// ydistribute(50) {
|
||||||
// xdistribute(30) {
|
// xdistribute(30) {
|
||||||
// text3d("\"X\"");
|
// edge_cube(edges=LEFT);
|
||||||
// text3d("\"Y\"");
|
// edge_cube(edges=FRONT);
|
||||||
// text3d("\"Z\"");
|
// edge_cube(edges=RIGHT);
|
||||||
// }
|
|
||||||
// xdistribute(30) {
|
|
||||||
// cuboid(20,chamfer=3,edges="X");
|
|
||||||
// cuboid(20,chamfer=3,edges="Y");
|
|
||||||
// cuboid(20,chamfer=3,edges="Z");
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// ydistribute(10) {
|
// xdistribute(30) {
|
||||||
// xdistribute(30) {
|
// edge_cube(edges=TOP);
|
||||||
// text3d("\"ALL\"");
|
// edge_cube(edges=BACK);
|
||||||
// text3d("\"NONE\"");
|
// edge_cube(edges=BOTTOM);
|
||||||
// }
|
// }
|
||||||
// xdistribute(30) {
|
// }
|
||||||
// cuboid(20,chamfer=3,edges="ALL");
|
// Figure(3D): Named Edge Sets
|
||||||
// cuboid(20,chamfer=3,edges="NONE");
|
// 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
|
// 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=[]) =
|
function edges(v, except=[]) =
|
||||||
(is_string(v) || is_vector(v) || is_edge_array(v))? edges([v], except=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]) :
|
(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(
|
||||||
normalize_edges(sum([for (x=v) edge_set(x)])) -
|
normalize_edges(sum([for (x=v) _edge_set(x)])) -
|
||||||
sum([for (x=except) 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
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue