Skip to content
Revar Desmera edited this page Mar 27, 2019 · 10 revisions

Library File constants.scad

Useful Constants. To use this, add the following line to the top of your file.

include <BOSL/constants.scad>

Table of Contents

  1. General Constants

  2. Directional Vectors

  3. Vector Aliases

  4. Pre-Orientation Alignments

  5. Standard Orientations

  6. Orientations Rotated 90º

  7. Orientations Rotated 180º

  8. Orientations Rotated 270º

  9. Individual Edges

  10. Sets of Edges

  11. Edge Helpers


1. General Constants

PRINTER_SLOP

Description: 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.


2. Directional Vectors

Vectors useful for rotate(), mirror(), and align arguments for cuboid(), cyl(), etc.

V_LEFT

Description: Vector pointing left. [-1,0,0]

Example: Usage with align

cuboid(20, align=V_LEFT);

V_LEFT Example


V_RIGHT

Description: Vector pointing right. [1,0,0]

Example: Usage with align

cuboid(20, align=V_RIGHT);

V_RIGHT Example


V_FWD

Description: Vector pointing forward. [0,-1,0]

Example: Usage with align

cuboid(20, align=V_FWD);

V_FWD Example


V_BACK

Description: Vector pointing back. [0,1,0]

Example: Usage with align

cuboid(20, align=V_BACK);

V_BACK Example


V_DOWN

Description: Vector pointing down. [0,0,-1]

Example: Usage with align

cuboid(20, align=V_DOWN);

V_DOWN Example


V_UP

Description: Vector pointing up. [0,0,1]

Example: Usage with align

cuboid(20, align=V_UP);

V_UP Example


V_ALLPOS

Description: Vector pointing right, back, and up. [1,1,1]

Example: Usage with align

  cuboid(20, align=V_ALLPOS);

V_ALLPOS Example


V_ALLNEG

Description: Vector pointing left, forwards, and down. [-1,-1,-1]

Example: Usage with align

  cuboid(20, align=V_ALLNEG);

V_ALLNEG Example


V_ZERO

Description: Zero vector. Centered. [0,0,0]

Example: Usage with align

  cuboid(20, align=V_ZERO);

V_ZERO Example


3. Vector Aliases

Useful aliases for use with align.

V_CENTER

Description: Centered, alias to V_ZERO.


V_ABOVE

Description: Vector pointing up, alias to V_UP.


V_BELOW

Description: Vector pointing down, alias to V_DOWN.


V_BEFORE

Description: Vector pointing forward, alias to V_FWD.


V_BEHIND

Description: Vector pointing back, alias to V_BACK.


V_TOP

Description: Vector pointing up, alias to V_UP.


V_BOTTOM

Description: Vector pointing down, alias to V_DOWN.


V_FRONT

Description: Vector pointing forward, alias to V_FWD.


V_REAR

Description: Vector pointing back, alias to V_BACK.


4. Pre-Orientation Alignments

Constants for pre-orientation alignments.

ALIGN_POS

Description: Align the axis-positive end to the origin.

Example 1: orient=ORIENT_X

  cyl(d1=10, d2=5, h=20, orient=ORIENT_X, align=ALIGN_POS);

ALIGN_POS Example 1

Example 2: orient=ORIENT_Y

  cyl(d1=10, d2=5, h=20, orient=ORIENT_Y, align=ALIGN_POS);

ALIGN_POS Example 2

Example 3: orient=ORIENT_Z

  cyl(d1=10, d2=5, h=20, orient=ORIENT_Z, align=ALIGN_POS);

ALIGN_POS Example 3

Example 4: orient=ORIENT_XNEG

  cyl(d1=10, d2=5, h=20, orient=ORIENT_XNEG, align=ALIGN_POS);

ALIGN_POS Example 4

Example 5: orient=ORIENT_YNEG

  cyl(d1=10, d2=5, h=20, orient=ORIENT_YNEG, align=ALIGN_POS);

ALIGN_POS Example 5

Example 6: orient=ORIENT_ZNEG

  cyl(d1=10, d2=5, h=20, orient=ORIENT_ZNEG, align=ALIGN_POS);

ALIGN_POS Example 6


ALIGN_CENTER

Description: Align centered.


ALIGN_NEG

Description: Align the axis-negative end to the origin.

Example 1: orient=ORIENT_X

  cyl(d1=10, d2=5, h=20, orient=ORIENT_X, align=ALIGN_NEG);

ALIGN_NEG Example 1

Example 2: orient=ORIENT_Y

  cyl(d1=10, d2=5, h=20, orient=ORIENT_Y, align=ALIGN_NEG);

ALIGN_NEG Example 2

Example 3: orient=ORIENT_Z

  cyl(d1=10, d2=5, h=20, orient=ORIENT_Z, align=ALIGN_NEG);

ALIGN_NEG Example 3

Example 4: orient=ORIENT_XNEG

  cyl(d1=10, d2=5, h=20, orient=ORIENT_XNEG, align=ALIGN_NEG);

ALIGN_NEG Example 4

Example 5: orient=ORIENT_YNEG

  cyl(d1=10, d2=5, h=20, orient=ORIENT_YNEG, align=ALIGN_NEG);

ALIGN_NEG Example 5

Example 6: orient=ORIENT_ZNEG

  cyl(d1=10, d2=5, h=20, orient=ORIENT_ZNEG, align=ALIGN_NEG);

ALIGN_NEG Example 6


5. Standard Orientations

Orientations for cyl(), prismoid(), etc. They take the form of standard [X,Y,Z] rotation angles for rotating a vertical shape into the given orientations.

Figure 1: Standard Orientations

Standard Orientations Figure 1

ORIENT_X

Description: Orient along the X axis.


ORIENT_Y

Description: Orient along the Y axis.


ORIENT_Z

Description: Orient along the Z axis.


ORIENT_XNEG

Description: Orient reversed along the X axis.


ORIENT_YNEG

Description: Orient reversed along the Y axis.


ORIENT_ZNEG

Description: Orient reversed along the Z axis.


6. Orientations Rotated 90º

Orientations for cyl(), prismoid(), etc. They take the form of standard [X,Y,Z] rotation angles for rotating a vertical shape into the given orientations.

Figure 2: Orientations Rotated 90º

Orientations Rotated 90º Figure 2

ORIENT_X_90

Description: Orient along the X axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_Y_90

Description: Orient along the Y axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_Z_90

Description: Orient along the Z axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_XNEG_90

Description: Orient reversed along the X axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_YNEG_90

Description: Orient reversed along the Y axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_ZNEG_90

Description: Orient reversed along the Z axis, then rotate 90 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


7. Orientations Rotated 180º

Orientations for cyl(), prismoid(), etc. They take the form of standard [X,Y,Z] rotation angles for rotating a vertical shape into the given orientations.

Figure 3: Orientations Rotated 180º

Orientations Rotated 180º Figure 3

ORIENT_X_180

Description: Orient along the X axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_Y_180

Description: Orient along the Y axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_Z_180

Description: Orient along the Z axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_XNEG_180

Description: Orient reversed along the X axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_YNEG_180

Description: Orient reversed along the Y axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_ZNEG_180

Description: Orient reversed along the Z axis, then rotate 180 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


8. Orientations Rotated 270º

Orientations for cyl(), prismoid(), etc. They take the form of standard [X,Y,Z] rotation angles for rotating a vertical shape into the given orientations.

Figure 4: Orientations Rotated 270º

Orientations Rotated 270º Figure 4

ORIENT_X_270

Description: Orient along the X axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_Y_270

Description: Orient along the Y axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_Z_270

Description: Orient along the Z axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_XNEG_270

Description: Orient reversed along the X axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_YNEG_270

Description: Orient reversed along the Y axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


ORIENT_ZNEG_270

Description: Orient reversed along the Z axis, then rotate 270 degrees counter-clockwise on that axis, as seen when facing the origin from that axis orientation.


9. Individual Edges

Constants for specifying edges for cuboid(), etc.

EDGE_TOP_BK

Description: Top Back edge.


EDGE_TOP_FR

Description: Top Front edge.


EDGE_BOT_FR

Description: Bottom Front Edge.


EDGE_BOT_BK

Description: Bottom Back Edge.


EDGE_TOP_RT

Description: Top Right edge.


EDGE_TOP_LF

Description: Top Left edge.


EDGE_BOT_LF

Description: Bottom Left edge.


EDGE_BOT_RT

Description: Bottom Right edge.


EDGE_BK_RT

Description: Back Right edge.


EDGE_BK_LF

Description: Back Left edge.


EDGE_FR_LF

Description: Front Left edge.


EDGE_FR_RT

Description: Front Right edge.


10. Sets of Edges

Constants for specifying edges for cuboid(), etc.

EDGES_X_TOP

Description: Both X-aligned Top edges.


EDGES_X_BOT

Description: Both X-aligned Bottom edges.


EDGES_X_FR

Description: Both X-aligned Front edges.


EDGES_X_BK

Description: Both X-aligned Back edges.


EDGES_X_ALL

Description: All four X-aligned edges.


EDGES_Y_TOP

Description: Both Y-aligned Top edges.


EDGES_Y_BOT

Description: Both Y-aligned Bottom edges.


EDGES_Y_LF

Description: Both Y-aligned Left edges.


EDGES_Y_RT

Description: Both Y-aligned Right edges.


EDGES_Y_ALL

Description: All four Y-aligned edges.


EDGES_Z_BK

Description: Both Z-aligned Back edges.


EDGES_Z_FR

Description: Both Z-aligned Front edges.


EDGES_Z_LF

Description: Both Z-aligned Left edges.


EDGES_Z_RT

Description: Both Z-aligned Right edges.


EDGES_Z_ALL

Description: All four Z-aligned edges.


EDGES_LEFT

Description: All four Left edges.


EDGES_RIGHT

Description: All four Right edges.


EDGES_FRONT

Description: All four Front edges.


EDGES_BACK

Description: All four Back edges.


EDGES_BOTTOM

Description: All four Bottom edges.


EDGES_TOP

Description: All four Top edges.


EDGES_NONE

Description: No edges.


EDGES_ALL

Description: All edges.


11. Edge Helpers

EDGE_OFFSETS

Description: Array of XYZ offsets to the center of each edge.


corner_edge_count()

Description: Counts how many given edges intersect at a specific corner.

Argument What it does
edges Standard edges array.
v Vector pointing to the corner to count edge intersections at.

Clone this wiki locally