From 53b7d7a6284c90c03b71c9076dd8e5806008a9e5 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 15 May 2019 19:23:26 +0800 Subject: [PATCH] refactor --- src/m_translation.scad | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/m_translation.scad b/src/m_translation.scad index a44e2ff6..04f19335 100644 --- a/src/m_translation.scad +++ b/src/m_translation.scad @@ -8,15 +8,18 @@ * **/ -function _to_tvect(v) = - len(v) == 3 ? v : ( - len(v) == 2 ? [v[0], v[1], 0] : ( - len(v) == 1 ? [v[0], 0, 0] : [v, 0, 0] - ) +include <__private__/__is_float.scad>; + +function _to_3_elems_translation_vect(v) = + let(leng = len(v)) + leng == 3 ? v : ( + leng == 2 ? [v[0], v[1], 0] : [v[0], 0, 0] ); +function _to_translation_vect(v) = __is_float(v) ? [v, 0, 0] : _to_3_elems_translation_vect(v); + function m_translation(v) = - let(vt = _to_tvect(v)) + let(vt = _to_translation_vect(v)) [ [1, 0, 0, vt[0]], [0, 1, 0, vt[1]],