From f511c281a54be1d80ebc9acc9b30405e0b94cc9b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 24 May 2017 10:04:15 +0800 Subject: [PATCH] refactored --- src/__private__/__polytransversals.scad | 20 ++++++++++++++++++++ src/polytransversals.scad | 23 ++--------------------- 2 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 src/__private__/__polytransversals.scad diff --git a/src/__private__/__polytransversals.scad b/src/__private__/__polytransversals.scad new file mode 100644 index 00000000..6fcb8647 --- /dev/null +++ b/src/__private__/__polytransversals.scad @@ -0,0 +1,20 @@ +function __polytransversals(transversals) = + let( + leng_trs = len(transversals), + leng_tr = len(transversals[0]), + lefts = [ + for(i = [1:leng_trs - 2]) + let(tr = transversals[leng_trs - i]) + tr[0] + ], + rights = [ + for(i = [1:leng_trs - 2]) + let(tr = transversals[i]) + tr[leng_tr - 1] + ] + ) concat( + transversals[0], + rights, + __reverse(transversals[leng_trs - 1]), + lefts + ); \ No newline at end of file diff --git a/src/polytransversals.scad b/src/polytransversals.scad index 0642c10f..f715aeb5 100644 --- a/src/polytransversals.scad +++ b/src/polytransversals.scad @@ -12,29 +12,10 @@ **/ include <__private__/__reverse.scad>; +include <__private__/__polytransversals.scad>; module polytransversals(transversals) { - leng_trs = len(transversals); - leng_tr = len(transversals[0]); - - lefts = [ - for(i = [1:leng_trs - 2]) - let(tr = transversals[leng_trs - i]) - tr[0] - ]; - - rights = [ - for(i = [1:leng_trs - 2]) - let(tr = transversals[i]) - tr[leng_tr - 1] - ]; - polygon( - concat( - transversals[0], - rights, - __reverse(transversals[leng_trs - 1]), - lefts - ) + __polytransversals(transversals) ); } \ No newline at end of file