Created
April 23, 2022 13:44
-
-
Save sorki/611dd83388b5f51fbd88b1927c6d7a14 to your computer and use it in GitHub Desktop.
Displace implicit function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Prelude | |
import Control.Applicative (pure) | |
import Graphics.Implicit | |
import Graphics.Implicit.Definitions | |
import Graphics.Implicit.Primitives | |
displaced | |
:: (Object obj vec) | |
=> (vec -> Double) | |
-> obj | |
-> obj | |
displaced dispFn obj = implicit | |
(\i -> | |
let prim = getImplicit obj i | |
disp = dispFn i | |
in prim + disp | |
) | |
-- XXX | |
((*2) <$> getBox obj) | |
mul (V3 a b c) = a * b * c | |
-- main = writeSTL 1 "displaced.stl" $ displaced (\v@(V3 x y z) -> mul ( (cos . (*(2))) <$> v ) ) $ sphere 10 | |
main = writeSTL 1 "displaced.stl" $ displaced (\v@(V3 x y z) -> mul ( | |
V3 (sin . (*(2)) $ x) | |
(cos . (*(1/2)) $ y) | |
(sin z) | |
) ) $ sphere 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment