From 75894c04e6702ea7f8894b3425994338fcf5fe53 Mon Sep 17 00:00:00 2001 From: Isaac Poole Date: Thu, 28 Nov 2024 08:19:59 -0500 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(enclosure):=20str?= =?UTF-8?q?eamline=20offset=20radius=20calculation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - introduce offsetRadius variable for clarity and reuse - replace repeated calculations with offsetRadius variable --- hardware/enclosure/index.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hardware/enclosure/index.ts b/hardware/enclosure/index.ts index e8bfdd2..e2284a1 100644 --- a/hardware/enclosure/index.ts +++ b/hardware/enclosure/index.ts @@ -35,26 +35,28 @@ const dimensions = { }; const sectionGeo = ({ isEndSection }: SectionOptions) => { + const offsetRadius = rod.diameter / 2 + dimensions.thickness / 2; + const shafts = [ - arc({ radius: rod.diameter / 2 + dimensions.thickness / 2 }), + arc({ radius: offsetRadius }), arc({ - radius: rod.diameter / 2 + dimensions.thickness / 2, + radius: offsetRadius, center: [0, dimensions.face], }), arc({ - radius: rod.diameter / 2 + dimensions.thickness / 2, + radius: offsetRadius, center: [-dimensions.back, 0], }), ]; const face = line([ - [rod.diameter / 2 + dimensions.thickness / 2, dimensions.face], - [rod.diameter / 2 + dimensions.thickness / 2, 0], + [offsetRadius, dimensions.face], + [offsetRadius, 0], ]); const back = line([ - [-dimensions.back, -(rod.diameter / 2 + dimensions.thickness / 2)], - [0, -(rod.diameter / 2 + dimensions.thickness / 2)], + [-dimensions.back, -offsetRadius], + [0, -offsetRadius], ]); const buttonGeo = (i: number) => @@ -74,7 +76,7 @@ const sectionGeo = ({ isEndSection }: SectionOptions) => { [ -section.width(isEndSection) / buttons.countPerSection / 2, 0, - -(rod.diameter / 2 + dimensions.thickness / 2), + -offsetRadius, ], buttonGeo(1), buttonGeo(2)