Haskell-Things / ImplicitCAD

A math-inspired CAD program in haskell. CSG, bevels, and shells; 2D & 3D geometry; 2D gcode generation...
https://implicitcad.org/
GNU Affero General Public License v3.0
1.39k stars 142 forks source link

More functions as parameters #38

Closed brad closed 9 months ago

brad commented 12 years ago

I love the ability of ImplicitCAD to use a function for the twist parameter of linear_extrude and I think it would be amazing is this were available in more places. Some good examples would be the radius of circles and spheres. Maybe even the radius of a cylinder, which could vary with the height as well as the arc angle.

I was hoping to produce a wavy circle with this:

Prelude Graphics.Implicit> writeSVG 1 "test.svg" (let r x = sin(x) in circle(r))

<interactive>:1:51:
    Couldn't match expected type `Float' with actual type `a0 -> a0'
    Expected type: Graphics.Implicit.Definitions.â

    In the first argument of `circle', namely `(r)'
    In the expression: circle (r)
colah commented 12 years ago

Hey Brad,

I agree that it would be really cool to have more function parameters. The types that would develop if we made everything polymorphic in Haskell might be a bit tedious, but we could certainly have circleVariableRadius :: (ℝ -> ℝ) -> Obj2 or something... I was actually thinking of something similar with an eye to making gears.

So this is coming!

By the way, the shape would have been a Rose with k=1, had it been implemented. Roses are pretty :)

brad commented 12 years ago

Yeah, I guess it makes sense to use the different function for that. Good call on the Rose function, my mistake, I guess the function I wanted was more like "r x = 20 + sin(x)"?

colah commented 12 years ago

That's just going to shift it. You want a higher frequency. Something like r x = 20 + sin(5*x) is likely closer to what you want.

brad commented 12 years ago

Ahh, schooled again. Thank you :)

colah commented 12 years ago

A comment: linear_extrude now supports scale and translate options on the extopenscad end.

julialongtin commented 9 months ago

Closing this, as "more" is not a goal that has a defined ending. :)