author | Michael Krelin <hacker@klever.net> | 2016-02-27 14:18:56 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2016-02-27 14:18:56 (UTC) |
commit | f39bbe4d0a4b3b556f93aecf5fee37974817dc12 (patch) (unidiff) | |
tree | 5055f128629b92afb920cabc9bc8ca3e3b8fcea5 /delta.jscad | |
parent | ba0d2b52cac7c0ff12fcefb41211177e31963cdc (diff) | |
download | redelta-f39bbe4d0a4b3b556f93aecf5fee37974817dc12.zip redelta-f39bbe4d0a4b3b556f93aecf5fee37974817dc12.tar.gz redelta-f39bbe4d0a4b3b556f93aecf5fee37974817dc12.tar.bz2 |
extended U from other projects
-rw-r--r-- | delta.jscad | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/delta.jscad b/delta.jscad index 326d172..35a777c 100644 --- a/delta.jscad +++ b/delta.jscad | |||
@@ -125,49 +125,78 @@ var CD = { | |||
125 | // TODO: properly calculate | 125 | // TODO: properly calculate |
126 | rv.column_r = rv.circumscription_r - 48.29; | 126 | rv.column_r = rv.circumscription_r - 48.29; |
127 | return rv; | 127 | return rv; |
128 | })(), | 128 | })(), |
129 | duetholder: (function() { | 129 | duetholder: (function() { |
130 | var rv = {}; | 130 | var rv = {}; |
131 | var s = CONFIG.base.sl; | 131 | var s = CONFIG.base.sl; |
132 | var l = CONFIG.duet.hole_spacing.x; | 132 | var l = CONFIG.duet.hole_spacing.x; |
133 | var w = CONFIG.duet.hole_spacing.y; | 133 | var w = CONFIG.duet.hole_spacing.y; |
134 | var h = s*Math.cos(Math.PI/6); | 134 | var h = s*Math.cos(Math.PI/6); |
135 | var h1 = h*(1-l/s); | 135 | var h1 = h*(1-l/s); |
136 | rv.distance = (h1-w)/3; // hole to side | 136 | rv.distance = (h1-w)/3; // hole to side |
137 | return rv; | 137 | return rv; |
138 | })() | 138 | })() |
139 | }; | 139 | }; |
140 | console.log(CONFIG); console.log(CD); | 140 | console.log(CONFIG); console.log(CD); |
141 | 141 | ||
142 | var U = { | 142 | var U = { |
143 | hypotenuse: function(a,b) { | 143 | hypotenuse: function(a,b) { |
144 | return Math.sqrt(Math.pow(a,2)+Math.pow(b,2)); | 144 | return Math.sqrt(Math.pow(a,2)+Math.pow(b,2)); |
145 | }, | 145 | }, |
146 | peek: function(x,m) { | 146 | peek: function(x,m) { |
147 | console.log(x,m); | 147 | console.log(x,m); |
148 | return x; | 148 | return x; |
149 | }, | ||
150 | axes: function U_axes(o) { | ||
151 | if(!o) o = {}; | ||
152 | var l = o.l||20, g = o.g||0.7; | ||
153 | return union([ | ||
154 | CSG.roundedCylinder({start:[0,0,0],end:[l,0,0]}).setColor([1,0,0,g]), | ||
155 | CSG.roundedCylinder({start:[0,0,0],end:[0,l,0]}).setColor([0,1,0,g]), | ||
156 | CSG.roundedCylinder({start:[0,0,0],end:[0,0,l]}).setColor([0,0,1,g]) | ||
157 | ]); | ||
158 | }, | ||
159 | pextract: function U_pextract(a,pn) { // TODO: monkeypatch Array | ||
160 | return a.map(function(x){return x[pn]}); | ||
161 | }, | ||
162 | hole: function U_hole(o) { | ||
163 | var r = o.r||o.radius||(o.d/2)||(o.diameter/2); | ||
164 | var n = Math.max(Math.round(4*r),4); | ||
165 | return CSG.cylinder({ | ||
166 | start: o.start, end: o.end, | ||
167 | radius: r/Math.cos(Math.PI/n), | ||
168 | resultion: n | ||
169 | }); | ||
170 | }, | ||
171 | |||
172 | upright: function U_upright() { return new CSG.Connector([0,0,0],[0,0,1],[1,0,0]) }, | ||
173 | downright: function U_downright() { return new CSG.Connector([0,0,0],[0,0,-1],[1,0,0]) }, | ||
174 | P: function U_P(x) { | ||
175 | if(!x.properties.P) return x; | ||
176 | return x.connectTo(x.properties.P,U.upright(),false,0); | ||
149 | } | 177 | } |
178 | |||
150 | }; | 179 | }; |
151 | 180 | ||
152 | /* {h:,w:} */ | 181 | /* {h:,w:} */ |
153 | function nut(o) { | 182 | function nut(o) { |
154 | var rv = CSG.cylinder({ | 183 | var rv = CSG.cylinder({ |
155 | start:[0,0,0],end:[0,0,o.h], | 184 | start:[0,0,0],end:[0,0,o.h], |
156 | radius: o.w/2/Math.cos(Math.PI/6), | 185 | radius: o.w/2/Math.cos(Math.PI/6), |
157 | resolution: 6 | 186 | resolution: 6 |
158 | }); | 187 | }); |
159 | rv.properties.axis_connector = new CSG.Connector([0,0,0],[0,0,1],[0,1,0]); | 188 | rv.properties.axis_connector = new CSG.Connector([0,0,0],[0,0,1],[0,1,0]); |
160 | return rv; | 189 | return rv; |
161 | } | 190 | } |
162 | 191 | ||
163 | var E3DV6 = { | 192 | var E3DV6 = { |
164 | dimensions: { | 193 | dimensions: { |
165 | big_d: 22.3, | 194 | big_d: 22.3, |
166 | 195 | ||
167 | }, | 196 | }, |
168 | heatsink: function() { | 197 | heatsink: function() { |
169 | var fn = 16; | 198 | var fn = 16; |
170 | var z=0; | 199 | var z=0; |
171 | var unite = [ {d:16,h:3.7},{d:12,h:6},{d:16,h:3} ].map(function(x) { | 200 | var unite = [ {d:16,h:3.7},{d:12,h:6},{d:16,h:3} ].map(function(x) { |
172 | return CSG.cylinder({ | 201 | return CSG.cylinder({ |
173 | start: [0,0,z], end: [0,0,z-=x.h], | 202 | start: [0,0,z], end: [0,0,z-=x.h], |