Skip to content

Commit

Permalink
♻️ refactor(enclosure): streamline offset radius calculation
Browse files Browse the repository at this point in the history
- introduce offsetRadius variable for clarity and reuse
- replace repeated calculations with offsetRadius variable
  • Loading branch information
isfopo committed Nov 28, 2024
1 parent 8b9c5b2 commit 75894c0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions hardware/enclosure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand All @@ -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)
Expand Down

0 comments on commit 75894c0

Please sign in to comment.