Nabble has removed Mailing-list integration.
Posts created here DO NOT GET SENT TO THE MAILING LIST.
Mailing-list emails DO NOT GET POSTED TO THE FORUM.
So basically the Forum is now out of date, we are looking into migrating the history.

More efficient use of lookup for animations?

4 messages
Open this post in threaded view
|

More efficient use of lookup for animations?

 Hi, I'm new to OpenSCAD's animation feature, and I'm playing around with some simple animation scripts. Generally, it's very useful, however, I'm running into a fairly annoying problem. I started with this guide (https://www.instructables.com/id/Animating-with-OpenSCAD/) which recommended wrapping your use of lookup() in a function like:     loc = [         [0,0,0], // initial position         [0,0,0], // top body shifts over slightly         [0,0,10], // lifts leg up         [0,5,10], // moves leg forward         [0,5,0], // puts leg down         [0,5,0], // puts leg down         [0,5,0], // puts leg down         [0,5,0], // puts leg down         [0,5,0], // puts leg down         [0,5,0], // puts leg down     ];     function xyz(t,i) = lookup(t, [         [0/len(loc),loc[0][i]],         [1/len(loc),loc[1][i]],         [2/len(loc),loc[2][i]],         [3/len(loc),loc[3][i]],         [4/len(loc),loc[4][i]],         [5/len(loc),loc[5][i]],         [6/len(loc),loc[6][i]],         [7/len(loc),loc[7][i]],         [8/len(loc),loc[8][i]],         [9/len(loc),loc[9][i]],         [10/len(loc),loc[10][i]],     ]); Then you can animate something by simply plugging in a call to `xyz(\$t, <0|1|2>)` inside a translate or rotate statement. Yet, as you can see, this violates the DRY rule, and makes for some very tedious and unnecessary code. For every new step added to my `loc` array, I need to add an entry to the array inside my `xyz()` function as well. Is there any way to rewrite my `xyz()` function to generate the array on demand so I don't have to maintain what are effectively duplicate arrays? Is a more efficient way to do this that I'm not seeing? _______________________________________________ OpenSCAD mailing list [hidden email] http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Open this post in threaded view
|