Quantcast

access points in for loop

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

access points in for loop

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

Re: access points in for loop

nophead
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: access points in for loop

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