discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Please, why does this functin not compile?

P
PYM
Tue, Aug 4, 2015 2:53 PM

Hello,

i ws working on calculting bezier curves with Casteljau algorithm, but my
test program wont compile due to a syntax error. I cant find it, can you?

Requires:
https://github.com/openscad/list-comprehension-demos
https://github.com/openscad/list-comprehension-demos
https://github.com/openscad/scad-utils
https://github.com/openscad/scad-utils

CODE

use <list-comprehension-demos/sweep.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
use <scad-utils/lists.scad>

bezier_points2 = [
[1,1],
[3,2],
[5,1]];

function getpt(a,b,i) = [ b[0]i + a[0](1-i),b[1]i + a[1](1-i)];

function bezier(bezpoints,g) = [ for( i= [0:1/g:1])
bezier_helper(bezpoints,i) ];

function bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] :
bezier_helper([ for( v = bezpoints) (let m = v + 1) getpt(points[v],
points[m], g)]) , g);

//!echo(bezier(bezier_points2, 10));

--
View this message in context: http://forum.openscad.org/Please-why-does-this-functin-not-compile-tp13440.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Hello, i ws working on calculting bezier curves with Casteljau algorithm, but my test program wont compile due to a syntax error. I cant find it, can you? Requires: https://github.com/openscad/list-comprehension-demos <https://github.com/openscad/list-comprehension-demos> https://github.com/openscad/scad-utils <https://github.com/openscad/scad-utils> CODE ------ use <list-comprehension-demos/sweep.scad> use <scad-utils/transformations.scad> use <scad-utils/shapes.scad> use <scad-utils/lists.scad> bezier_points2 = [ [1,1], [3,2], [5,1]]; function getpt(a,b,i) = [ b[0]*i + a[0]*(1-i),b[1]*i + a[1]*(1-i)]; function bezier(bezpoints,g) = [ for( i= [0:1/g:1]) bezier_helper(bezpoints,i) ]; function bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] : bezier_helper([ for( v = bezpoints) (let m = v + 1) getpt(points[v], points[m], g)]) , g); //!echo(bezier(bezier_points2, 10)); -- View this message in context: http://forum.openscad.org/Please-why-does-this-functin-not-compile-tp13440.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Tue, Aug 4, 2015 3:54 PM

There are two: let should be outside the brackets and there is an extra ,
g) at the end.

This has correct syntax but doesn't work

function bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] :
bezier_helper([ for( v = bezpoints) let( m = v + 1) getpt(points[v],
points[m], g)]);

On 4 August 2015 at 15:53, PYM pm@pixelyourmind.de wrote:

Hello,

i ws working on calculting bezier curves with Casteljau algorithm, but my
test program wont compile due to a syntax error. I cant find it, can you?

Requires:
https://github.com/openscad/list-comprehension-demos
https://github.com/openscad/list-comprehension-demos
https://github.com/openscad/scad-utils
https://github.com/openscad/scad-utils

CODE

use <list-comprehension-demos/sweep.scad>
use <scad-utils/transformations.scad>
use <scad-utils/shapes.scad>
use <scad-utils/lists.scad>

bezier_points2 = [
[1,1],
[3,2],
[5,1]];

function getpt(a,b,i) = [ b[0]i + a[0](1-i),b[1]i + a[1](1-i)];

function bezier(bezpoints,g) = [ for( i= [0:1/g:1])
bezier_helper(bezpoints,i) ];

function bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] :
bezier_helper([ for( v = bezpoints) (let m = v + 1) getpt(points[v],
points[m], g)]) , g);

//!echo(bezier(bezier_points2, 10));

--
View this message in context:
http://forum.openscad.org/Please-why-does-this-functin-not-compile-tp13440.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


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

There are two: let should be outside the brackets and there is an extra , g) at the end. This has correct syntax but doesn't work function bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] : bezier_helper([ for( v = bezpoints) let( m = v + 1) getpt(points[v], points[m], g)]); On 4 August 2015 at 15:53, PYM <pm@pixelyourmind.de> wrote: > Hello, > > i ws working on calculting bezier curves with Casteljau algorithm, but my > test program wont compile due to a syntax error. I cant find it, can you? > > Requires: > https://github.com/openscad/list-comprehension-demos > <https://github.com/openscad/list-comprehension-demos> > https://github.com/openscad/scad-utils > <https://github.com/openscad/scad-utils> > > CODE > ------ > > use <list-comprehension-demos/sweep.scad> > use <scad-utils/transformations.scad> > use <scad-utils/shapes.scad> > use <scad-utils/lists.scad> > > bezier_points2 = [ > [1,1], > [3,2], > [5,1]]; > > function getpt(a,b,i) = [ b[0]*i + a[0]*(1-i),b[1]*i + a[1]*(1-i)]; > > function bezier(bezpoints,g) = [ for( i= [0:1/g:1]) > bezier_helper(bezpoints,i) ]; > > function bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] : > bezier_helper([ for( v = bezpoints) (let m = v + 1) getpt(points[v], > points[m], g)]) , g); > > > //!echo(bezier(bezier_points2, 10)); > > > > -- > View this message in context: > http://forum.openscad.org/Please-why-does-this-functin-not-compile-tp13440.html > Sent from the OpenSCAD mailing list archive at Nabble.com. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
R
rickan
Tue, Aug 4, 2015 7:57 PM

It looks to me like it's not the , g) at the end that's extra but the ) in
front of the , g).

This also compiles:

unction bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] :
bezier_helper([ for( v = bezpoints) let (m = v + 1) getpt(points[v],
points[m], g)], g);

And it matches the bezier_helper definition.

--
View this message in context: http://forum.openscad.org/Please-why-does-this-functin-not-compile-tp13440p13444.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

It looks to me like it's not the , g) at the end that's extra but the ) in front of the , g). This also compiles: unction bezier_helper(bezpoints,g) = (len(bezpoints) == 1) ? points[0] : bezier_helper([ for( v = bezpoints) let (m = v + 1) getpt(points[v], points[m], g)], g); And it matches the bezier_helper definition. -- View this message in context: http://forum.openscad.org/Please-why-does-this-functin-not-compile-tp13440p13444.html Sent from the OpenSCAD mailing list archive at Nabble.com.