discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

building flat array with successive functions and tests in functions....

BB
Bruno Boettcher
Thu, May 21, 2020 6:46 PM

Hello!

on the path to more complexity i hit another wall:

in roundPoint i can't add the test? it gives me a syntax error in  front of
the for loop?

and the main problem, i can't feed this to a polygon, each function adds a
nesting to the produced array, how do i avoid this?

my son had the ... delightful.... idea of drawing a dragon, so i started on
something to build the beak of it... i begun to draw the rough shape , and
once having that shape i wanted to smooth it out, but it didn't work as i
supposed it would...

thanks for any help!
Bruno

echo("poly",  kieferPoly(b  =40,l = 70,lw=10, d=2)) ;

function baseForm(x, b, l) = (b!= 0)? 4l/(bb) xx - l:0;
function curveAngle(l, y0, ueber, lw,hprim) =  (l+y0 <= ueber)? 105-2*lw -
atan((ueber -y0)/hprim):(y0 == 0)? 0:-atan(y0/hprim);

function roundPoint(pt,rad, res = 3,above = true) =
[
//(above == true)?
for(n = [0:1:res])
let (w = 180 + 180/resn)
[pt[0]+rad
cos(w),pt[1], pt[2]+radsin(w)]
// :
//        for(n = [0:1:res])
//            let (w = 180/res
n)
//              [pt[0]+radcos(w),pt[1], pt[2]+radsin(w)]
];

function transvCut(x,y,z,d=1,res=3) =
[
roundPoint([x,y,z],d,res),
roundPoint([0,y,z+x],d,res, above = 0),
roundPoint([-x,y,z],d,res)
];

function kieferPoly(b,l,lw=10, d=2) =
let(curve = sqrt(ll+ bb/4))
let(hprim = curvecos(lw))
let(  ueber = curve
sin(lw))
[
for(x = [-b/2: 1 : 0])
let(y0 = baseForm(x,b,l))
let(beta = curveAngle(l, y0, ueber, lw,hprim))
transvCut(x,y0,curve*cos(beta)-hprim,d),
];

--
ciao
Bruno

---==========
http://nohkumado.eu/, http://bboett.free.frhttp://aikido.nohkumado.eu/,
http://bboett.free.fr
http://aikido.zorn.free.fr

Hello! on the path to more complexity i hit another wall: in roundPoint i can't add the test? it gives me a syntax error in front of the for loop? and the main problem, i can't feed this to a polygon, each function adds a nesting to the produced array, how do i avoid this? my son had the ... delightful.... idea of drawing a dragon, so i started on something to build the beak of it... i begun to draw the rough shape , and once having that shape i wanted to smooth it out, but it didn't work as i supposed it would... thanks for any help! Bruno echo("poly", kieferPoly(b =40,l = 70,lw=10, d=2)) ; function baseForm(x, b, l) = (b!= 0)? 4*l/(b*b) *x*x - l:0; function curveAngle(l, y0, ueber, lw,hprim) = (l+y0 <= ueber)? 105-2*lw - atan((ueber -y0)/hprim):(y0 == 0)? 0:-atan(y0/hprim); function roundPoint(pt,rad, res = 3,above = true) = [ //(above == true)? for(n = [0:1:res]) let (w = 180 + 180/res*n) [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)] // : // for(n = [0:1:res]) // let (w = 180/res*n) // [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)] ]; function transvCut(x,y,z,d=1,res=3) = [ roundPoint([x,y,z],d,res), roundPoint([0,y,z+x],d,res, above = 0), roundPoint([-x,y,z],d,res) ]; function kieferPoly(b,l,lw=10, d=2) = let(curve = sqrt(l*l+ b*b/4)) let(hprim = curve*cos(lw)) let( ueber = curve*sin(lw)) [ for(x = [-b/2: 1 : 0]) let(y0 = baseForm(x,b,l)) let(beta = curveAngle(l, y0, ueber, lw,hprim)) transvCut(x,y0,curve*cos(beta)-hprim,d), ]; -- ciao Bruno =========================================== http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, <http://bboett.free.fr> http://aikido.zorn.free.fr
TP
Torsten Paul
Thu, May 21, 2020 6:55 PM

Yes, the list comprehension is not a general expression.
I'm not sure it's possible to change that.

Both branches look the same anyway, so I'd use

w = 180/res*n + above ? 180 : 0

As for nesting, check this post:
http://forum.openscad.org/2D-SVG-concat-points-point-no-output-loops-amp-conditionals-vector-declarations-td29068.html#a29070

You can drop one nesting level using 'each'

For some extra ideas for drawing using math, check
out https://www.desmos.com/art

ciao,
Torsten.

Yes, the list comprehension is not a general expression. I'm not sure it's possible to change that. Both branches look the same anyway, so I'd use w = 180/res*n + above ? 180 : 0 As for nesting, check this post: http://forum.openscad.org/2D-SVG-concat-points-point-no-output-loops-amp-conditionals-vector-declarations-td29068.html#a29070 You can drop one nesting level using 'each' For some extra ideas for drawing using math, check out https://www.desmos.com/art ciao, Torsten.
DM
Doug Moen
Thu, May 21, 2020 8:49 PM

You can't use a a?b:c conditional within a list comprehension. You must use if (a) b else c instead.
Try replacing the list comprehension with this:

[
if (above == true)
for(n = [0:1:res])
let (w = 180 + 180/resn)
[pt[0]+rad
cos(w),pt[1], pt[2]+radsin(w)]
else
for(n = [0:1:res])
let (w = 180/res
n)
[pt[0]+radcos(w),pt[1], pt[2]+radsin(w)]
];

Doug Moen.

You can't use a a?b:c conditional within a list comprehension. You must use if (a) b else c instead. Try replacing the list comprehension with this: > [ > if (above == true) > for(n = [0:1:res]) > let (w = 180 + 180/res*n) > [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)] > else > for(n = [0:1:res]) > let (w = 180/res*n) > [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)] > ]; > Doug Moen.
BB
Bruno Boettcher
Fri, May 22, 2020 2:52 PM

thanks , that worked indeed!

Am Do., 21. Mai 2020 um 22:51 Uhr schrieb Doug Moen doug@moens.org:

You can't use a a?b:c conditional within a list comprehension. You must
use if (a) b else c instead.
Try replacing the list comprehension with this:

[
if (above == true)
for(n = [0:1:res])
let (w = 180 + 180/resn)
[pt[0]+rad
cos(w),pt[1], pt[2]+radsin(w)]
else
for(n = [0:1:res])
let (w = 180/res
n)
[pt[0]+radcos(w),pt[1], pt[2]+radsin(w)]
];

Doug Moen.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

thanks , that worked indeed! Am Do., 21. Mai 2020 um 22:51 Uhr schrieb Doug Moen <doug@moens.org>: > You can't use a a?b:c conditional within a list comprehension. You must > use if (a) b else c instead. > Try replacing the list comprehension with this: > > [ > if (above == true) > for(n = [0:1:res]) > let (w = 180 + 180/res*n) > [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)] > else > for(n = [0:1:res]) > let (w = 180/res*n) > [pt[0]+rad*cos(w),pt[1], pt[2]+rad*sin(w)] > ]; > > > Doug Moen. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- ciao Bruno =========================================== http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, <http://bboett.free.fr> http://aikido.zorn.free.fr
BB
Bruno Boettcher
Fri, May 22, 2020 2:52 PM

great! each solved the stuff!
thanks!

Am Do., 21. Mai 2020 um 20:56 Uhr schrieb Torsten Paul <Torsten.Paul@gmx.de

:

Yes, the list comprehension is not a general expression.
I'm not sure it's possible to change that.

Both branches look the same anyway, so I'd use

w = 180/res*n + above ? 180 : 0

As for nesting, check this post:

http://forum.openscad.org/2D-SVG-concat-points-point-no-output-loops-amp-conditionals-vector-declarations-td29068.html#a29070

You can drop one nesting level using 'each'

For some extra ideas for drawing using math, check
out https://www.desmos.com/art

ciao,
Torsten.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

great! each solved the stuff! thanks! Am Do., 21. Mai 2020 um 20:56 Uhr schrieb Torsten Paul <Torsten.Paul@gmx.de >: > Yes, the list comprehension is not a general expression. > I'm not sure it's possible to change that. > > Both branches look the same anyway, so I'd use > > w = 180/res*n + above ? 180 : 0 > > As for nesting, check this post: > > http://forum.openscad.org/2D-SVG-concat-points-point-no-output-loops-amp-conditionals-vector-declarations-td29068.html#a29070 > > You can drop one nesting level using 'each' > > For some extra ideas for drawing using math, check > out https://www.desmos.com/art > > ciao, > Torsten. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- ciao Bruno =========================================== http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, <http://bboett.free.fr> http://aikido.zorn.free.fr