# access points in for loop

3 messages
Open this post in threaded view
|
Report Content as Inappropriate

## access points in for loop

 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 ??     }
Open this post in threaded view
|
Report Content as Inappropriate

## Re: access points in for loop

 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 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 [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org