ImplicitCAD icon indicating copy to clipboard operation
ImplicitCAD copied to clipboard

More functions as parameters

Open brad opened this issue 12 years ago • 5 comments

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)

brad avatar Mar 12 '12 20:03 brad

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 :)

colah avatar Mar 15 '12 20:03 colah

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)"?

brad avatar Mar 16 '12 16:03 brad

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.

colah avatar Mar 17 '12 04:03 colah

Ahh, schooled again. Thank you :)

brad avatar Mar 17 '12 15:03 brad

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

colah avatar Aug 02 '12 20:08 colah

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

julialongtin avatar Dec 17 '23 17:12 julialongtin