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
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.
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
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
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.