mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-11 04:55:41 +03:00
Tidy Haskell examples
Both in Examples dir and README.
This commit is contained in:
parent
64c595f7bc
commit
6d4162e137
@ -2,8 +2,9 @@
|
||||
import Graphics.Implicit
|
||||
|
||||
out = union [
|
||||
rectR 0 (-40,-40) (40,40),
|
||||
translate (40,40) (circle 30) ]
|
||||
squareR 0 True (80, 80)
|
||||
, translate (40, 40) $ circle 30
|
||||
]
|
||||
|
||||
main = writeSVG 2 "example11.svg" out
|
||||
|
||||
|
@ -2,7 +2,8 @@
|
||||
import Graphics.Implicit
|
||||
|
||||
out = unionR 14 [
|
||||
rectR 0 (-40,-40) (40,40),
|
||||
translate (40,40) (circle 30) ]
|
||||
squareR 0 (80, 80)
|
||||
, translate (40,40) $ circle 30
|
||||
]
|
||||
|
||||
main = writeSVG 2 "example12.svg" out
|
||||
|
@ -2,7 +2,8 @@
|
||||
import Graphics.Implicit
|
||||
|
||||
out = union [
|
||||
rect3R 0 (0,0,0) (20,20,20),
|
||||
translate (20,20,20) (sphere 15) ]
|
||||
cubeR 0 False (20, 20, 20)
|
||||
, translate (20, 20, 20) $ sphere 15
|
||||
]
|
||||
|
||||
main = writeSTL 1 "example13.stl" out
|
||||
|
@ -3,22 +3,20 @@ import Prelude ((<$>), ($), zip3, fmap, fromIntegral, (*), (/))
|
||||
import Graphics.Implicit (union, translate, rect3R, writeSTL)
|
||||
import Graphics.Implicit.Definitions (Fastℕ, ℝ, ℝ3, SymbolicObj3)
|
||||
|
||||
|
||||
default (Fastℕ, ℝ)
|
||||
|
||||
object2 :: SymbolicObj3
|
||||
object2 = squarePipe (10,10,10) 1 100
|
||||
object2 = squarePipe (10, 10, 10) 1 100
|
||||
where
|
||||
squarePipe :: ℝ3 -> ℝ -> ℝ -> SymbolicObj3
|
||||
squarePipe (x,y,z) diameter precision =
|
||||
union
|
||||
((\start-> translate start
|
||||
$ rect3R 0 (0,0,0) (diameter,diameter,diameter)
|
||||
((\start -> translate start
|
||||
$ cubeR 0 False (diameter, diameter, diameter)
|
||||
)
|
||||
<$>
|
||||
zip3 (fmap (\n->(fromIntegral n/precision)*x) [0..100])
|
||||
(fmap (\n->(fromIntegral n/precision)*y) [0..100])
|
||||
(fmap (\n->(fromIntegral n/precision)*z) [0..100]))
|
||||
zip3 (fmap (\n -> (fromIntegral n / precision) * x) [0..100])
|
||||
(fmap (\n -> (fromIntegral n / precision) * y) [0..100])
|
||||
(fmap (\n -> (fromIntegral n / precision) * z) [0..100]))
|
||||
|
||||
main = writeSTL 1 "example17.stl" object2
|
||||
|
||||
|
15
README.md
15
README.md
@ -196,8 +196,9 @@ Everything you saw above can be done with the Haskell API. For example, a simple
|
||||
import Graphics.Implicit
|
||||
|
||||
out = union [
|
||||
rectR 0 (-40,-40) (40,40),
|
||||
translate (40,40) (circle 30) ]
|
||||
squareR 0 True (80, 80)
|
||||
, translate (40, 40) (circle 30)
|
||||
]
|
||||
|
||||
main = writeSVG 2 "test.svg" out
|
||||
```
|
||||
@ -212,8 +213,9 @@ A rounded union:
|
||||
import Graphics.Implicit
|
||||
|
||||
out = unionR 14 [
|
||||
rectR 0 (-40,-40) (40,40),
|
||||
translate (40,40) (circle 30) ]
|
||||
squareR 0 True (80, 80)
|
||||
, translate (80, 80) (circle 30)
|
||||
]
|
||||
|
||||
main = writeSVG 2 "test.svg" out
|
||||
```
|
||||
@ -227,8 +229,9 @@ A simple 3D example:
|
||||
import Graphics.Implicit
|
||||
|
||||
out = union [
|
||||
rect3R 0 (0,0,0) (20,20,20),
|
||||
translate (20,20,20) (sphere 15) ]
|
||||
cubeR 0 False (20, 20, 20)
|
||||
, translate (20, 20, 20) (sphere 15)
|
||||
]
|
||||
|
||||
main = writeSTL 1 "test.stl" out
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user