discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

access points in for loop

J
jazzjohn
Sat, Mar 18, 2017 6:54 PM

How do I access, within a loop,  the next point in a list of points?
I want to compute the angle between every pair of adjacent points.

points = [ [0,0],[25,20],[30,50],[17,50],[7,30],[10,45],[35,35]];

for (i=points)
{
translate(i) square(1);
//do something with the next point ??
}

--
View this message in context: http://forum.openscad.org/access-points-in-for-loop-tp20953.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

How do I access, within a loop, the next point in a list of points? I want to compute the angle between every pair of adjacent points. points = [ [0,0],[25,20],[30,50],[17,50],[7,30],[10,45],[35,35]]; for (i=points) { translate(i) square(1); //do something with the next point ?? } -- View this message in context: http://forum.openscad.org/access-points-in-for-loop-tp20953.html Sent from the OpenSCAD mailing list archive at Nabble.com.
NH
nop head
Sat, Mar 18, 2017 7:00 PM

points = [ [0,0],[25,20],[30,50],[17,50],[7,30],[10,45],[35,35]];

for (i=[0: len(points) - 1])
{
translate(points[i]) square(1);
//do something with the next point ??
something(points[(i+1) % len(points)]);
}

On 18 March 2017 at 18:54, jazzjohn jazzjohn@gmail.com wrote:

How do I access, within a loop,  the next point in a list of points?
I want to compute the angle between every pair of adjacent points.

points = [ [0,0],[25,20],[30,50],[17,50],[7,30],[10,45],[35,35]];

for (i=points)
{
translate(i) square(1);
//do something with the next point ??
}

--
View this message in context: http://forum.openscad.org/
access-points-in-for-loop-tp20953.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

points = [ [0,0],[25,20],[30,50],[17,50],[7,30],[10,45],[35,35]]; for (i=[0: len(points) - 1]) { translate(points[i]) square(1); //do something with the next point ?? something(points[(i+1) % len(points)]); } On 18 March 2017 at 18:54, jazzjohn <jazzjohn@gmail.com> wrote: > How do I access, within a loop, the next point in a list of points? > I want to compute the angle between every pair of adjacent points. > > > points = [ [0,0],[25,20],[30,50],[17,50],[7,30],[10,45],[35,35]]; > > for (i=points) > { > translate(i) square(1); > //do something with the next point ?? > } > > > > -- > View this message in context: http://forum.openscad.org/ > access-points-in-for-loop-tp20953.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 >
J
jazzjohn
Sat, Mar 18, 2017 7:17 PM

Ahh... I knew there had to be syntax that would work... thanks!

--
View this message in context: http://forum.openscad.org/access-points-in-for-loop-tp20953p20955.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Ahh... I knew there had to be syntax that would work... thanks! -- View this message in context: http://forum.openscad.org/access-points-in-for-loop-tp20953p20955.html Sent from the OpenSCAD mailing list archive at Nabble.com.