-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpositioning.scad
124 lines (114 loc) · 3.49 KB
/
positioning.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
// POSITIONING.SCAD
// by ISC 2021-09
//
// routing to position 2D elements
// used by Notch library
//
// PTop(), PBottom(), PLeft(), PRight()
// PFTop(), PFBottom(), PFLeft(), PFRight()
// MUp(), MDown(), MLeft(), MRight()
//
// POSITIONING 2-D
//
// run me!!!
//Positioning_Demo();
module Positioning_Demo() {
cWidth = 80;
cHeight = 100;
// normal top/left
// bottom/right - mirror
canvas();
target();
color("red") PTop (cHeight) target();
color("green") PBottom(cHeight) target();
color("blue") PLeft (cWidth ) target();
color("orange") PRight (cWidth ) target();
// flipped top/left
// bottom/right - mirror
translate([120,0,0]) {
canvas();
target();
color("red") PFTop (cHeight) target();
color("green") PFBottom(cHeight) target();
color("blue") PFLeft (cWidth ) target();
color("orange") PFRight (cWidth ) target();
}
// move only
translate([240,0,0]) {
canvas();
circle(5);
color("red") MUp (20) circle(5);
color("green") MDown (20) circle(5);
color("blue") MLeft (20) circle(5);
color("orange") MRight(20) circle(5);
}
module canvas() {
color("gray")
translate([0,0,-1])
square([cWidth,cHeight],center=true);
color("red") translate([0,0,1]) {
square([cWidth,1],center=true);
square([1,cHeight],center=true);
}
}
module target() {
linear_extrude(1)
difference() {
polygon([[-15,0],[15,0],[15,-15],[-15,-5]]);
circle(3);
}
}
}
module PTop(canvas,leftRight=0) {
// move up
translate([leftRight,canvas/2,0]) children();
}
module PFTop(canvas,leftRight=0) {
// move up
// flip left/right
translate([leftRight,canvas/2,0]) rotate([180,0,180]) children();
}
module PBottom(canvas,leftRight=0) {
// move down
// mirror of PTop()
translate([leftRight,-canvas/2,0])
rotate([180,0,0])
children();
}
module PFBottom(canvas,leftRight=0) {
// move down
// mirror of PFTop()
translate([leftRight,-canvas/2,0]) rotate([0,0,180]) children();
}
module PLeft(canvas,upDown=0) {
// rotate CCW to left
translate([-canvas/2,upDown,0]) rotate([0,0,90]) children();
}
module PFLeft(canvas,upDown=0) {
// rotate CCW to left
// up/down flip
translate([-canvas/2,upDown,0]) rotate([0,0,-90]) rotate([180,0,0]) children();
}
module PRight(canvas,upDown=0) {
// move right
// mirror of PLeft();
translate([canvas/2,upDown,0]) rotate([0,0,90]) rotate([180,0,0]) children();
}
module PFRight(canvas,upDown=0) {
// move right
// mirror of PFLeft();
translate([canvas/2,upDown,0]) rotate([0,0,-90]) children();
}
module MUp(offset,leftRight=0) {
translate([leftRight,offset,0]) children();
}
module MDown(offset,leftRight=0) {
translate([leftRight,-offset,0]) children();
}
module MLeft(offset,upDown=0) {
translate([-offset,upDown,0]) children();
}
module MRight(offset,upDown=0) {
translate([offset,upDown,0]) children();
}