2019-02-12 02:24:41 +00:00
//////////////////////////////////////////////////////////////////////
2019-03-23 04:13:18 +00:00
// LibFile: constants.scad
// Useful Constants.
// To use this, add the following line to the top of your file.
// ```
2019-04-19 07:25:10 +00:00
// include <BOSL2/std.scad>
2019-03-23 04:13:18 +00:00
// ```
2019-02-12 02:24:41 +00:00
//////////////////////////////////////////////////////////////////////
2019-03-23 04:13:18 +00:00
// Section: General Constants
PRINTER_SLOP = 0.20 ; // The printer specific amount of slop in mm to print with to make parts fit exactly. You may need to override this value for your printer.
// Section: Directional Vectors
2019-04-23 03:55:03 +00:00
// Vectors useful for `rotate()`, `mirror()`, and `anchor` arguments for `cuboid()`, `cyl()`, etc.
2019-03-23 04:13:18 +00:00
2019-04-19 06:32:17 +00:00
// Constant: LEFT
2019-03-23 04:13:18 +00:00
// Description: Vector pointing left. [-1,0,0]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
// cuboid(20, anchor=LEFT);
2019-04-19 06:32:17 +00:00
LEFT = [ - 1 , 0 , 0 ] ;
2019-03-23 04:13:18 +00:00
2019-04-19 06:32:17 +00:00
// Constant: RIGHT
2019-03-23 04:13:18 +00:00
// Description: Vector pointing right. [1,0,0]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
// cuboid(20, anchor=RIGHT);
2019-04-19 06:32:17 +00:00
RIGHT = [ 1 , 0 , 0 ] ;
2019-03-23 04:13:18 +00:00
2019-05-08 05:42:44 +00:00
// Constant: FRONT
2019-03-23 04:13:18 +00:00
// Description: Vector pointing forward. [0,-1,0]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
2019-05-08 05:42:44 +00:00
// cuboid(20, anchor=FRONT);
FRONT = [ 0 , - 1 , 0 ] ;
2019-03-23 04:13:18 +00:00
2019-04-19 06:32:17 +00:00
// Constant: BACK
2019-03-23 04:13:18 +00:00
// Description: Vector pointing back. [0,1,0]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
// cuboid(20, anchor=BACK);
2019-04-19 06:32:17 +00:00
BACK = [ 0 , 1 , 0 ] ;
2019-03-23 04:13:18 +00:00
2019-05-08 05:42:44 +00:00
// Constant: BOTTOM
2019-03-23 04:13:18 +00:00
// Description: Vector pointing down. [0,0,-1]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
2019-05-08 05:42:44 +00:00
// cuboid(20, anchor=BOTTOM);
BOTTOM = [ 0 , 0 , - 1 ] ;
2019-03-23 04:13:18 +00:00
2019-05-08 05:42:44 +00:00
// Constant: TOP
2019-03-23 04:13:18 +00:00
// Description: Vector pointing up. [0,0,1]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
2019-05-08 05:42:44 +00:00
// cuboid(20, anchor=TOP);
TOP = [ 0 , 0 , 1 ] ;
2019-02-27 11:46:40 +00:00
2019-04-19 06:32:17 +00:00
// Constant: ALLPOS
2019-03-23 04:13:18 +00:00
// Description: Vector pointing right, back, and up. [1,1,1]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
2019-05-10 11:02:58 +00:00
// cuboid(20, anchor=ALLPOS);
2019-04-19 06:32:17 +00:00
ALLPOS = [ 1 , 1 , 1 ] ; // Vector pointing X+,Y+,Z+.
2019-03-23 04:13:18 +00:00
2019-04-19 06:32:17 +00:00
// Constant: ALLNEG
2019-03-23 04:13:18 +00:00
// Description: Vector pointing left, forwards, and down. [-1,-1,-1]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
2019-05-10 11:02:58 +00:00
// cuboid(20, anchor=ALLNEG);
2019-04-19 06:32:17 +00:00
ALLNEG = [ - 1 , - 1 , - 1 ] ; // Vector pointing X-,Y-,Z-.
2019-03-23 04:13:18 +00:00
2019-04-19 06:32:17 +00:00
// Constant: CENTER
2019-03-23 04:13:18 +00:00
// Description: Zero vector. Centered. [0,0,0]
2019-04-23 03:55:03 +00:00
// Example(3D): Usage with `anchor`
2019-05-10 11:02:58 +00:00
// cuboid(20, anchor=CENTER);
2019-04-19 06:32:17 +00:00
CENTER = [ 0 , 0 , 0 ] ; // Centered zero vector.
2019-03-23 04:13:18 +00:00
// Section: Vector Aliases
2019-04-23 03:55:03 +00:00
// Useful aliases for use with `anchor`.
2019-03-23 04:13:18 +00:00
2019-05-26 06:31:05 +00:00
CTR = CENTER ; // Zero vector, `[0,0,0]`. Alias to `CENTER`.
2019-05-08 05:42:44 +00:00
UP = TOP ; // Vector pointing up, alias to `TOP`.
DOWN = BOTTOM ; // Vector pointing down, alias to `BOTTOM`.
BTM = BOTTOM ; // Vector pointing down, alias to `BOTTOM`.
BOT = BOTTOM ; // Vector pointing down, alias to `BOTTOM`.
FWD = FRONT ; // Vector pointing forward, alias to `FRONT`.
FORWARD = FRONT ; // Vector pointing forward, alias to `FRONT`.
2019-04-19 06:32:17 +00:00
2019-02-16 08:55:35 +00:00
2019-03-23 04:13:18 +00:00
// CommonCode:
// orientations = [
2019-05-26 06:31:05 +00:00
// RIGHT, BACK, UP,
// LEFT, FWD, DOWN,
2019-03-23 04:13:18 +00:00
// ];
// axiscolors = ["red", "forestgreen", "dodgerblue"];
// module text3d(text, h=0.01, size=3) {
// linear_extrude(height=h, convexity=10) {
// text(text=text, size=size, valign="center", halign="center");
// }
// }
// module orient_cube(ang) {
// color("lightgray") cube(20, center=true);
// color(axiscolors.x) up ((20-1)/2+0.01) back ((20-1)/2+0.01) cube([18,1,1], center=true);
// color(axiscolors.y) up ((20-1)/2+0.01) right((20-1)/2+0.01) cube([1,18,1], center=true);
// color(axiscolors.z) back((20-1)/2+0.01) right((20-1)/2+0.01) cube([1,1,18], center=true);
// for (axis=[0:2], neg=[0:1]) {
2019-05-26 06:31:05 +00:00
// idx = axis + 3*neg;
// rot(ang, from=UP, to=orientations[idx]) {
2019-03-23 04:13:18 +00:00
// up(10) {
2019-03-27 11:33:26 +00:00
// fwd(4) color("black") text3d(text=str(ang), size=4);
// back(4) color(axiscolors[axis]) text3d(text=str(["X","Y","Z"][axis], ["+","NEG"][neg]), size=4);
2019-03-23 04:13:18 +00:00
// }
// }
// }
// }
2019-02-16 08:55:35 +00:00
2019-03-23 04:13:18 +00:00
2019-02-12 02:24:41 +00:00
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap