Skip to content
Newer
Older
100644 309 lines (230 sloc) 10.9 KB
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
1 ImplicitCAD: Math Inspired CAD
2 ==============================
3
2a15bbb @colah Adds "Try It" section to the README.
authored Oct 27, 2011
4 Introduction
5 ------------
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
6
c29dc7e @raghuugare Corrected small typos & added small improvements to README file...
raghuugare authored Sep 13, 2015
7 ImplicitCAD is a programmatic CAD program, implemented in [Haskell](https://www.haskell.org/). Unlike traditional CAD programs, programmatic CAD programs use text descriptions of objects, as in programming. Concepts like variables, control structures and abstraction are used, just as in programming. This provides a number of advantages:
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
8
9 - Objects can abstracted and reused
10 - Repetitive tasks can be automated
11 - Objects can be designed parametrically
12 - The usual tools for software development (like version control) can be used
13
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 24, 2016
14 A well known example of a programmatic CAD language and environment is [OpenSCAD](http://www.openscad.org/).
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
15
16 Generally, objects in programmatic CAD are built with Constructive Solid Geometry or CSG. Unions, intersections and differences of simpler shapes slowly build the object. ImplicitCAD supports all this and much more! For example, it provides rounded unions so that one can have smooth interfaces between objects.
17
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
18 It also directly provides some GCode generation, and has a parser for OpenSCAD to make it easier for people to transition/use.
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
19
a68f723 @colah Some updates to docs after 0.0.1 release.
authored Feb 6, 2012
20 ImplicitCAD is very much a work in progress. The author considers it ready for beta testers and greatly appreciates bug reports.
21
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
22
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
23 ExtOpenSCAD Examples
24 --------------------
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
25
c29dc7e @raghuugare Corrected small typos & added small improvements to README file...
raghuugare authored Sep 13, 2015
26 Let's being with OpenSCAD examples, since they're likely a more comfortable format than Haskell for most readers :)
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
27
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
28 ImplicitCAD supports a modified version of the OpenSCAD language, used by the popular programmatic CAD tool of the same name.
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
29
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
30 Generally, normal OpenSCAD code should work. For example, save the following as `example1.scad` (or grab it out of the Examples/ directory shipped with ImplicitCAD).
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
31
32 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
33 // example1.scad -- The union of a square and a circle.
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
34 union() {
35 square([80,80]);
8c4d54b @colah README fix.
authored Apr 18, 2012
36 translate ([80,80]) circle(30);
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
37 }
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
38 ```
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
39
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
40 Running `extopenscad example1.scad` will produce `example1.svg`, which will look like:
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
41
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
42 ![A Union of a Square and Circle](http://faikvm.com/ImplicitCAD/example1.svg)
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
43
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
44 You can read more about standard openscad functionality in the [OpenSCAD User Manual](http://en.wikibooks.org/wiki/OpenSCAD_User_Manual).
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
45
46 However, there are additional ImplicitCAD specific features. For example a rounded union:
47
48 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
49 //example2.escad -- A rounded union of a square and a circle.
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
50 union(r=14) {
51 square([80,80]);
8c4d54b @colah README fix.
authored Apr 18, 2012
52 translate ([80,80]) circle(30);
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
53 }
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
54 ```
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
55
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
56 ![A Rounded Union of a Square and Circle](http://faikvm.com/ImplicitCAD/example2.svg)
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
57
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
58 (For code like this that is not backwards compatible with OpenSCAD, it is recommended that you save it as a .escad file -- Extended OpenSCAD.)
59
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
60 Like openscad, ImplicitCAD supports extruding objects.
61
62 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
63 // example3.escad -- the extruded product of the union of five circles.
64 linear_extrude (height = 40, center=true){
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
65 union ( r = 8) {
66 circle (10);
67 translate ([22,0]) circle (10);
68 translate ([0,22]) circle (10);
69 translate ([-22,0]) circle (10);
70 translate ([0,-22]) circle (10);
71 }
72 }
73 ```
74
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
75 ![An Extrusion](http://faikvm.com/ImplicitCAD/example3.png)
76
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
77 And we allow you to twist them as you extrude.
78
79
80 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
81 // example4.escad -- the twisted extruded product of the union of five circles.
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
82 linear_extrude (height = 40, center=true, twist=90){
83 union ( r = 8) {
84 circle (10);
85 translate ([22,0]) circle (10);
86 translate ([0,22]) circle (10);
87 translate ([-22,0]) circle (10);
88 translate ([0,-22]) circle (10);
89 }
90 }
91 ```
92
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
93 ![An twisted extrusion](http://faikvm.com/ImplicitCAD/example4.png)
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
94
95 In fact, we've extended this to allow you to twist at non-constant rates and even reverse directions. You just make `twist` a function! (We're following the openscad convention of using degrees...)
96
97 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
98 // example5.escad -- the variably twisted extruded product of the union of 5 circles.
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
99 linear_extrude (height = 40, center=true, twist(h) = 35*cos(h*2*pi/60)) {
100 union ( r = 8) {
101 circle (10);
102 translate ([22,0]) circle (10);
103 translate ([0,22]) circle (10);
104 translate ([-22,0]) circle (10);
105 translate ([0,-22]) circle (10);
106 }
107 }
108 ```
109
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
110 ![A variably twisted ImplicitCAD extrusion](http://faikvm.com/ImplicitCAD/example5.png)
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
111
112 We also allow you to do rounded extrusions. See, we heard you like rounding, so we set this up so you can rounded extrude your rounded union...
113
114 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
115 // example6.escad -- A rounded extrusion of the rounded union of 5 circles.
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
116 linear_extrude (height = 40, center=true, r=5){
117 union ( r = 8) {
118 circle (10);
119 translate ([22,0]) circle (10);
120 translate ([0,22]) circle (10);
121 translate ([-22,0]) circle (10);
122 translate ([0,-22]) circle (10);
123 }
124 }
125 ```
126
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
127 ![A rounded extrusion made with ImplicitCAD](http://faikvm.com/ImplicitCAD/example6.png)
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
128
129 This is fully compatible with twisting, of course!
130
131 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
132 // example7.escad -- A twisted rounded extrusion of the rounded union of 5 circles.
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
133 linear_extrude (height = 40, center=true, twist=90, r=5){
134 union ( r = 8) {
135 circle (10);
136 translate ([22,0]) circle (10);
137 translate ([0,22]) circle (10);
138 translate ([-22,0]) circle (10);
139 translate ([0,-22]) circle (10);
140 }
141 }
142 ```
143
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
144 ![A rounded twisted extrusion](http://faikvm.com/ImplicitCAD/example7.png)
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
145
146
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
147 ImplicitCAD also provides full programmatic functionality, like variable assignment in loops, which are sadly absent in OpenSCAD. For example, the trivial program:
148
149 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
150 // Example8.escad -- variable assignment in loops.
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
151 a = 5;
152 for (c = [1, 2, 3]) {
153 echo(c);
154 a = a*c;
155 echo(a);
156 }
157 ```
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
158
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
159 Has the output:
160
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
161
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
162 ```
163 1.0
164 5.0
165 2.0
166 10.0
167 3.0
168 30.0
169 Nothing to render
170 ```
171
172 As a functional programmer, I couldn't resist adding some other niceties to the language. For example, function currying:
173
174 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
175 // Example9.escad -- function currying.
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
176 f = max(4);
177 echo(f(5));
178 echo(max(4,5));
179 ```
180 And some higher order functions, like my friend map:
181
182 ```c
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
183 // Example10.escad -- map!.
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
184 echo(map(cos, [0, pi/2, pi]));
185 ```
186
187 Haskell Examples
188 -----------------
189
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
190 Everything you saw above can be done with the Haskell API. For example, a simple 2D example, the same as our first ExtOpenSCAD one:
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
191
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 27, 2011
192 ```haskell
fa0344c @colah - Haddock documentation
authored Oct 29, 2011
193 import Graphics.Implicit
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
194
a671d05 @colah API change: CSG operations take lists.
authored Oct 31, 2011
195 out = union [
a68f723 @colah Some updates to docs after 0.0.1 release.
authored Feb 6, 2012
196 rectR 0 (-40,-40) (40,40),
a671d05 @colah API change: CSG operations take lists.
authored Oct 31, 2011
197 translate (40,40) (circle 30) ]
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
198
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
199 main = writeSVG 2 "test.svg" out
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
200 ```
8987b9a @colah Embeded SVGs in README.
authored Oct 25, 2011
201
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
202 ![A Union of a Square and Circle](http://faikvm.com/ImplicitCAD/SquareCircleUnion.png)
8987b9a @colah Embeded SVGs in README.
authored Oct 25, 2011
203
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
204
205 A rounded union:
206
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
207 ```haskell
fa0344c @colah - Haddock documentation
authored Oct 29, 2011
208 import Graphics.Implicit
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
209
a671d05 @colah API change: CSG operations take lists.
authored Oct 31, 2011
210 out = unionR 14 [
a68f723 @colah Some updates to docs after 0.0.1 release.
authored Feb 6, 2012
211 rectR 0 (-40,-40) (40,40),
a671d05 @colah API change: CSG operations take lists.
authored Oct 31, 2011
212 translate (40,40) (circle 30) ]
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
213
66cabfa @colah Show off more awesomeness in the README!
authored Feb 3, 2012
214 main = writeSVG 2 "test.svg" out
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
215 ```
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
216
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
217 ![A Rounded Union of a Square and Circle](http://faikvm.com/ImplicitCAD/SquareCircleUnionR.png)
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
218
219 A simple 3D example:
220
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
221 ```haskell
fa0344c @colah - Haddock documentation
authored Oct 29, 2011
222 import Graphics.Implicit
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
223
a671d05 @colah API change: CSG operations take lists.
authored Oct 31, 2011
224 out = union [
a68f723 @colah Some updates to docs after 0.0.1 release.
authored Feb 6, 2012
225 rect3R 0 (0,0,0) (20,20,20),
a671d05 @colah API change: CSG operations take lists.
authored Oct 31, 2011
226 translate (20,20,20) (sphere 15) ]
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
227
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
228 main = writeSTL 1 "test.stl" out
3754729 @colah README: Syntax Highlighting + image of 3D union.
authored Oct 28, 2011
229 ```
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
230
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
231 ![A Rounded Union of a Square and Circle](http://faikvm.com/ImplicitCAD/CubeSphereUnion.png)
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
232
b38c209 @colah README now shows ExtOpenSCAD examples
authored Jan 15, 2012
233 You can do a whole lot more!
234
709dbe3 @colah Better instructions for trying ImplicitCAD.
authored Oct 28, 2011
235 Try ImplicitCAD!
236 ----------------
237
238 1. Install GHC and cabal.
c29dc7e @raghuugare Corrected small typos & added small improvements to README file...
raghuugare authored Sep 13, 2015
239 * Debian/Ubuntu: `apt-get install ghc cabal-install`
709dbe3 @colah Better instructions for trying ImplicitCAD.
authored Oct 28, 2011
240 * Archlinux: `pacman -S ghc cabal-install`
241 * Red Hat/Fedora: `yum install ghc cabal-install`
242 * Mac OSX:
243 * Homebrew: `brew install ghc cabal-install`
dc936c9 @colah README update.
authored Feb 26, 2012
244 * *Fink doesn't seem to have a package for cabal* Install the Haskell Platform manually as described [here](http://hackage.haskell.org/platform/mac.html).
245 * Windows: Follows [these install instructions](http://hackage.haskell.org/platform/windows.html).
246 * Other unices: If your package manager does not include ghc and cabal you should install the Haskell platform as described [here](
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
247 2. You now have two options for installation:
248 * Latest release:
249 * Use cabal to install ImplicitCAD: `cabal update && cabal install implicit`
250 * Development version:
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
251 * Initialize your haskell environment: `cabal update`
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
252 * Git clone this repo: `git clone https://github.com/colah/ImplicitCAD.git`
253 * cd in: `cd ImplicitCAD/`
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
254 * install the dependencies: `cabal configure && cabal install --only-dependencies`
255 * cabal install it: `cabal install`
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
256 3. Try it!
257 * extopenscad test:
258 * Make a test file: `echo "circle(30);" > test.escad`
259 * Run extopencad: `extopenscad test.escad`
260 * Alternatively, `~/.cabal/bin/extopenscad test.escad` -- see bellow.
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
261 * Haskell ImplicitCAD test:
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
262 * Start ghci: `ghci`
263 * Load ImplicitCAD: `import Graphics.Implicit`
264 * Try it! `writeSVG 1 "test.svg" (circle 30)`
265 4. Known issues:
266 * extopenscad test results in `bash: extopenscad: command not found` (or similar for your shell)
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
267 * This probably means `~/.cabal/bin/` is not in your `$PATH` variable.
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
268 Try using `~/.cabal/bin/extopenscad` as your command instead.
1735ec5 @colah Fix Symbolic rounded intersection is rounded union bug.
authored Feb 12, 2012
269 * Haskell test results in `module is not loaded: 'Graphics.Implicit' (./Graphics/Implicit.hs)`
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
270 * This is most likely a problem with your Linux distro and cabal not playing nice.
271 GHC is not configured to see the ImplicitCAD libraries. You can confirm this by
de4ddf8 @colah Better install instructions.
authored Feb 7, 2012
272 try the test in `~/.cabal/lib/`. If that works, you should be able to use ghc
273 anywhere with the `-Ldir` or `-llib` options. Alternatively, some people have
274 permanently fixed this by doing the cabal install as root.
a68f723 @colah Some updates to docs after 0.0.1 release.
authored Feb 6, 2012
275
506e9e0 @colah Mention documentation in README
authored Nov 1, 2011
276 Documentation
277 -------------
278
279 Documentation can be generated from the source code of ImplicitCAD by Haddock by running `cabal haddock`.
280
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
281 Releases of ImplicitCAD are uploaded to HackageDB which, in addition to making them avaialable through `cabal install`, puts the generated documentation on the Internet. So you can read the documentation for the most recent release of ImplicitCAD, 0.0.1, [on HackageDB](http://hackage.haskell.org/packages/archive/implicit/0.0.3/doc/html/Graphics-Implicit.html) (for some reason the latest version doesn't seem to have built).
506e9e0 @colah Mention documentation in README
authored Nov 1, 2011
282
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
283 A description of the mathematical ideas underpinning ImplicitCAD are described in a [blog post on colah's blog](http://christopherolah.wordpress.com/2011/11/06/manipulation-of-implicit-functions-with-an-eye-on-cad/). Note that substantial changes have happened since that post. You can also look at the [0.0.3 relase notes](http://christopherolah.wordpress.com/2012/02/06/implicitcad-0-0-3-release/).
57e714d @colah Added references to a blog post I finished on how the math behind Imp…
authored Nov 5, 2011
284
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
285 Status
286 ------
287
288 ImplicitCAD is very much a work in progress.
289
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
290 What works (July 31, 2015 -- regressions are possible if not probable):
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
291
292 - CSG, bevelled CSG, shells.
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
293 - 2D output (svg).
294 - 3D output (stl).
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
295 - gcode generation for 2D to hacklab laser cutter. Not configurable.
296
297 What still needs to be done:
298
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
299 - gcode generation for 3D printers, gcode generator config.
300 - openscad parser for backwards compatibility (partially complete).
292e1b3 @colah README update.
authored Nov 2, 2011
301
302 And a wishlist of things further in the future:
303
304 - More optimisation
49b5788 @mmachenry changes from kalithea
mmachenry authored Jan 25, 2016
305 - Fewer bugs
5e03652 @raghuugare Small corrections...
raghuugare authored Sep 13, 2015
306 - OpenGL viewer?
307 - OpenGL acceleration?
e54a561 @colah - Fixed translate bug
authored Oct 24, 2011
308
Something went wrong with that request. Please try again.