mirror of
https://github.com/Haskell-Things/ImplicitCAD.git
synced 2024-09-11 04:55:41 +03:00
parent
b77993656e
commit
ed7e38f2c8
@ -2,8 +2,8 @@
|
||||
import Graphics.Implicit
|
||||
|
||||
out = union [
|
||||
squareR 0 True (80, 80)
|
||||
, translate (40, 40) $ circle 30
|
||||
square True (V2 80 80)
|
||||
, translate (V2 40 40) $ circle 30
|
||||
]
|
||||
|
||||
main = writeSVG 2 "example11.svg" out
|
||||
|
@ -1,9 +1,10 @@
|
||||
-- Example 12 - the rounded union of a square and a circle.
|
||||
import Control.Applicative (pure)
|
||||
import Graphics.Implicit
|
||||
|
||||
out = unionR 14 [
|
||||
squareR 0 (80, 80)
|
||||
, translate (40,40) $ circle 30
|
||||
square True (pure 80) -- pure 80 turns into (V2 80 80)
|
||||
, translate (pure 40) $ circle 30
|
||||
]
|
||||
|
||||
main = writeSVG 2 "example12.svg" out
|
||||
|
@ -1,9 +1,10 @@
|
||||
-- Example 13 - the rounded union of a cube and a sphere.
|
||||
import Control.Applicative (pure)
|
||||
import Graphics.Implicit
|
||||
|
||||
out = union [
|
||||
cubeR 0 False (20, 20, 20)
|
||||
, translate (20, 20, 20) $ sphere 15
|
||||
cube False (pure 20) -- same as (V3 20 20 20)
|
||||
, translate (pure 20) $ sphere 15
|
||||
]
|
||||
|
||||
main = writeSTL 1 "example13.stl" out
|
||||
|
@ -1,8 +1,12 @@
|
||||
import Control.Applicative (pure)
|
||||
import Graphics.Implicit
|
||||
import Graphics.Implicit.Definitions
|
||||
import Graphics.Implicit.Primitives
|
||||
|
||||
roundbox:: SymbolicObj3
|
||||
roundbox = implicit (\(x,y,z) -> x^4 + y^4 + z^4 - 15000) ((-20,-20,-20),(20,20,20))
|
||||
roundbox =
|
||||
implicit
|
||||
(\(V3 x y z) -> x^4 + y^4 + z^4 - 15000)
|
||||
(pure (-20), pure 20)
|
||||
|
||||
main = writeSTL 2 "example16.stl" roundbox
|
||||
|
@ -1,22 +1,25 @@
|
||||
-- Example 17, pulled from our benchmarking suite.
|
||||
import Prelude ((<$>), ($), zip3, fmap, fromIntegral, (*), (/))
|
||||
import Graphics.Implicit (union, translate, rect3R, writeSTL)
|
||||
import Control.Applicative (pure)
|
||||
import Prelude ((<$>), ($), zipWith3, fmap, fromIntegral, (*), (/), Bool(..))
|
||||
import Graphics.Implicit (cube, union, translate, writeSTL, V3(..))
|
||||
import Graphics.Implicit.Definitions (Fastℕ, ℝ, ℝ3, SymbolicObj3)
|
||||
|
||||
default (Fastℕ, ℝ)
|
||||
|
||||
object2 :: SymbolicObj3
|
||||
object2 = squarePipe (10, 10, 10) 1 100
|
||||
object2 = squarePipe (pure 10) 1 100
|
||||
where
|
||||
squarePipe :: ℝ3 -> ℝ -> ℝ -> SymbolicObj3
|
||||
squarePipe (x,y,z) diameter precision =
|
||||
squarePipe (V3 x y z) diameter precision =
|
||||
union
|
||||
((\start -> translate start
|
||||
$ cubeR 0 False (diameter, diameter, diameter)
|
||||
$ cube True (pure 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]))
|
||||
zipWith3
|
||||
V3
|
||||
(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
|
||||
|
Loading…
Reference in New Issue
Block a user