1use <BOSL/transforms.scad>
 2use <BOSL/math.scad>
 3include <BOSL/constants.scad>
 4
 5// Shows all the orientations on cubes in their correct rotations.
 6
 7orientations = [
 8	ORIENT_X,        ORIENT_Y,        ORIENT_Z,
 9	ORIENT_XNEG,     ORIENT_YNEG,     ORIENT_ZNEG,
10
11	ORIENT_X_90,     ORIENT_Y_90,     ORIENT_Z_90,
12	ORIENT_XNEG_90,  ORIENT_YNEG_90,  ORIENT_ZNEG_90,
13
14	ORIENT_X_180,    ORIENT_Y_180,    ORIENT_Z_180,
15	ORIENT_XNEG_180, ORIENT_YNEG_180, ORIENT_ZNEG_180,
16
17	ORIENT_X_270,    ORIENT_Y_270,    ORIENT_Z_270,
18	ORIENT_XNEG_270, ORIENT_YNEG_270, ORIENT_ZNEG_270
19];
20
21
22axisdiam = 0.5;
23axislen = 12;
24axislbllen = 15;
25axiscolors = ["red", "forestgreen", "dodgerblue"];
26
27module text3d(text, h=0.01, size=3) {
28	linear_extrude(height=h, convexity=10) {
29		text(text=text, size=size, valign="center", halign="center");
30	}
31}
32
33module dottedline(l, d) for(y = [0:d*3:l]) up(y) sphere(d=d);
34
35module orient_cubes() {
36	color(axiscolors[0]) {
37		yrot( 90) cylinder(h=axislen, d=axisdiam, center=false);
38		right(axislbllen) rot([90,0,0]) text3d(text="X+");
39		yrot(-90) dottedline(l=axislen, d=axisdiam);
40		left(axislbllen) rot([90,0,180]) text3d(text="X-");
41	}
42	color(axiscolors[1]) {
43		xrot(-90) cylinder(h=axislen, d=axisdiam, center=false);
44		back(axislbllen) rot([90,0,90]) text3d(text="Y+");
45		xrot( 90) dottedline(l=axislen, d=axisdiam);
46		fwd(axislbllen) rot([90,0,-90]) text3d(text="Y-");
47	}
48	color(axiscolors[2])  {
49		cylinder(h=axislen, d=axisdiam, center=false);
50		up(axislbllen) rot([0,-90,90+$vpr[2]]) text3d(text="Z+");
51		xrot(180) dottedline(l=axislen, d=axisdiam);
52		down(axislbllen) rot([0,90,-90+$vpr[2]]) text3d(text="Z-");
53	}
54
55
56	for (ang = [0:90:270]) {
57		translate(cylindrical_to_xyz(40, ang+90, 0)) {
58			color("lightgray") cube(20, center=true);
59		}
60	}
61
62	for (axis=[0:2], neg=[0:1], ang = [0:90:270]) {
63		idx = axis + 3*neg + 6*ang/90;
64		translate(cylindrical_to_xyz(40, ang+90, 0)) {
65			rotate(orientations[idx]) {
66				up(10) {
67					ydistribute(8) {
68						color("black") text3d(text=str(ang, "ยบ"), size=5);
69						color(axiscolors[axis]) text3d(text=str(["X","Y","Z"][axis], ["+","-"][neg]), size=5);
70					}
71				}
72			}
73		}
74	}
75}
76
77
78//rotate(a=180, v=[1,1,0])
79orient_cubes();
80
81
82
83// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap