### Is it possible to create a array of coordinates from an array of moves and how do I realize this? MH
Matthieu Hendriks
Sun, Nov 5, 2023 5:52 AM

every vector /array element gives the move in x and/or y direction
starting from [0,0]

moves=[[0,0],[-5,0],[0,10],[3,0],...]

the resulting coordinates  should be:

coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...]

I was thinking of something like :

moves=[[0,0],[-5,0],[0,10],[3,0]];
coordinates=[[0,0]];

for(i=[1:1:len(moves-1)]) {

coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]];
}

this of course gives me a syntax error, but I was wondering how to
realize this?

Groet Matthieu

every vector /array element gives the move in x and/or y direction starting from [0,0] moves=[[0,0],[-5,0],[0,10],[3,0],...] the resulting coordinates should be: coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...] I was thinking of something like : moves=[[0,0],[-5,0],[0,10],[3,0]]; coordinates=[[0,0]]; for(i=[1:1:len(moves-1)]) { coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]]; } this of course gives me a syntax error, but I was wondering how to realize this? Groet Matthieu ------------------------- ------------------------- SP
Sanjeev Prabhakar
Sun, Nov 5, 2023 6:27 AM

Long back I wrote this function in openscad

//function is used as input to another function

// function is used like a turtle move to create 2d shapes.
// following example will create a rectangle with sides 10 x 5:
// sec=pts([[0,0],[10,0],[0,5],[-10,0]]); // starts at [0,0] then moves 10
units to +x direction then moves 5 units towards +y direction and then
moves 10 units to -x direction

I am no longer using these functions, but should work

On Sun, 5 Nov, 2023, 11:22 am Matthieu Hendriks via Discuss, <

every vector /array element gives the move in x and/or y direction
starting from [0,0]

moves=[[0,0],[-5,0],[0,10],[3,0],...]

the resulting coordinates  should be:

coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...]

I was thinking of something like :

moves=[[0,0],[-5,0],[0,10],[3,0]];
coordinates=[[0,0]];

for(i=[1:1:len(moves-1)]) {

coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]];
}

## this of course gives me a syntax error, but I was wondering how to realize this? Groet Matthieu

To unsubscribe send an email to discuss-leave@lists.openscad.org

Long back I wrote this function in openscad //function is used as input to another function function add_p(p,p1=[0,0],n,i=0)= n==0?p1:add_p(p,[p[i].x+p1.x,p[i].y+p1.y],n-1,i+1); // function is used like a turtle move to create 2d shapes. // following example will create a rectangle with sides 10 x 5: // sec=pts([[0,0],[10,0],[0,5],[-10,0]]); // starts at [0,0] then moves 10 units to +x direction then moves 5 units towards +y direction and then moves 10 units to -x direction function pts(p)=[for(n=[1:len(p)])add_p(p=p,p1=[0,0],n=n,i=0)]; I am no longer using these functions, but should work On Sun, 5 Nov, 2023, 11:22 am Matthieu Hendriks via Discuss, < discuss@lists.openscad.org> wrote: > every vector /array element gives the move in x and/or y direction > starting from [0,0] > > moves=[[0,0],[-5,0],[0,10],[3,0],...] > > the resulting coordinates should be: > > coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...] > > I was thinking of something like : > > moves=[[0,0],[-5,0],[0,10],[3,0]]; > coordinates=[[0,0]]; > > for(i=[1:1:len(moves-1)]) { > > coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]]; > } > > this of course gives me a syntax error, but I was wondering how to realize > this? > Groet Matthieu > ------------------------------ > > ------------------------------ > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > MH
Matthieu Hendriks
Sun, Nov 5, 2023 9:58 AM

It still works. :) Tnx.

Groet Matthieu

Sanjeev Prabhakar via Discuss schreef op 2023-11-05 07:27:

Long back I wrote this function in openscad

//function is used as input to another function

// function is used like a turtle move to create 2d shapes.
// following example will create a rectangle with sides 10 x 5:
// sec=pts([[0,0],[10,0],[0,5],[-10,0]]); // starts at [0,0] then moves
10 units to +x direction then moves 5 units towards +y direction and
then moves 10 units to -x direction

I am no longer using these functions, but should work

On Sun, 5 Nov, 2023, 11:22 am Matthieu Hendriks via Discuss,

every vector /array element gives the move in x and/or y direction
starting from [0,0]

moves=[[0,0],[-5,0],[0,10],[3,0],...]

the resulting coordinates  should be:

coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...]

I was thinking of something like :

moves=[[0,0],[-5,0],[0,10],[3,0]];
coordinates=[[0,0]];

for(i=[1:1:len(moves-1)]) {
coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]];
}

this of course gives me a syntax error, but I was wondering how to
realize this?

Groet Matthieu

To unsubscribe send an email to discuss-leave@lists.openscad.org

To unsubscribe send an email to discuss-leave@lists.openscad.org

It still works. :) Tnx. Groet Matthieu ------------------------- ------------------------- Sanjeev Prabhakar via Discuss schreef op 2023-11-05 07:27: > Long back I wrote this function in openscad > > //function is used as input to another function > > function add_p(p,p1=[0,0],n,i=0)= > n==0?p1:add_p(p,[p[i].x+p1.x,p[i].y+p1.y],n-1,i+1); > > // function is used like a turtle move to create 2d shapes. > // following example will create a rectangle with sides 10 x 5: > // sec=pts([[0,0],[10,0],[0,5],[-10,0]]); // starts at [0,0] then moves > 10 units to +x direction then moves 5 units towards +y direction and > then moves 10 units to -x direction > > function pts(p)=[for(n=[1:len(p)])add_p(p=p,p1=[0,0],n=n,i=0)]; > > I am no longer using these functions, but should work > > On Sun, 5 Nov, 2023, 11:22 am Matthieu Hendriks via Discuss, > <discuss@lists.openscad.org> wrote: > >> every vector /array element gives the move in x and/or y direction >> starting from [0,0] >> >> moves=[[0,0],[-5,0],[0,10],[3,0],...] >> >> the resulting coordinates should be: >> >> coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...] >> >> I was thinking of something like : >> >> moves=[[0,0],[-5,0],[0,10],[3,0]]; >> coordinates=[[0,0]]; >> >> for(i=[1:1:len(moves-1)]) { >> coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]]; >> } >> >> this of course gives me a syntax error, but I was wondering how to >> realize this? >> >> Groet Matthieu >> >> ------------------------- >> >> ------------------------- >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org J
jon
Sun, Nov 5, 2023 10:30 AM

Would BOSL2's Turtle functions help here?

On 11/5/2023 1:52 AM, Matthieu Hendriks via Discuss wrote:

every vector /array element gives the move in x and/or y direction
starting from [0,0]

moves=[[0,0],[-5,0],[0,10],[3,0],...]

the resulting coordinates  should be:

coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...]

I was thinking of something like :

moves=[[0,0],[-5,0],[0,10],[3,0]];
coordinates=[[0,0]];

for(i=[1:1:len(moves-1)]) {
coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]];
}

this of course gives me a syntax error, but I was wondering how to
realize this?

## Groet Matthieu

To unsubscribe send an email todiscuss-leave@lists.openscad.org

Would BOSL2's Turtle functions help here? https://github.com/BelfrySCAD/BOSL2/wiki/turtle3d.scad On 11/5/2023 1:52 AM, Matthieu Hendriks via Discuss wrote: > > every vector /array element gives the move in x and/or y direction > starting from [0,0] > > moves=[[0,0],[-5,0],[0,10],[3,0],...] > > the resulting coordinates  should be: > > coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...] > > I was thinking of something like : > > moves=[[0,0],[-5,0],[0,10],[3,0]]; > coordinates=[[0,0]]; > > for(i=[1:1:len(moves-1)]) { > coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]]; > } > > this of course gives me a syntax error, but I was wondering how to > realize this? > > Groet Matthieu > ------------------------------------------------------------------------ > ------------------------------------------------------------------------ > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org AM
Sun, Nov 5, 2023 12:26 PM

I think he wants the 2D version, which is quite a bit simpler:

On Sun, Nov 5, 2023 at 5:30 AM jon via Discuss discuss@lists.openscad.org
wrote:

Would BOSL2's Turtle functions help here?

On 11/5/2023 1:52 AM, Matthieu Hendriks via Discuss wrote:

every vector /array element gives the move in x and/or y direction
starting from [0,0]

moves=[[0,0],[-5,0],[0,10],[3,0],...]

the resulting coordinates  should be:

coordinates=[[0,0],[-5,0],[-5,10],[-2,10],...]

I was thinking of something like :

moves=[[0,0],[-5,0],[0,10],[3,0]];
coordinates=[[0,0]];

for(i=[1:1:len(moves-1)]) {

coordinates[i]=[coordinates[i-1]+moves[i],coordinates[i-1]+moves[i]];
}