diff --git a/components/calcValues.vue b/components/calcValues.vue index 6f72d88..e5bcf0f 100644 --- a/components/calcValues.vue +++ b/components/calcValues.vue @@ -17,7 +17,7 @@ const min_length = use_min_length() const parametric = reactive({ length: { min: min_length.value, - max: 2400, + max: 2466, step: 1, }, total_length: { @@ -33,7 +33,7 @@ const parametric = reactive({ }) const form_state = reactive({ length: fence_section.value * 1000, - fence_length: 100, + fence_length: 104, height: 100 + lamelles_count.value * parametric.height.step, total_length: total_length.value, total_length_mm: fence_section.value * 1000, @@ -69,30 +69,29 @@ const changeParametres = () => { if (form_state.total_length_mm < form_state.length) { form_state.length = form_state.total_length_mm } - form_state.total_length_mm = form_state.total_length * 1000 - const total_without_pillar = form_state.total_length_mm - form_state.fence_length - if (form_state.auto_length) { + let { fence_length, total_length_mm, auto_length, length } = form_state + length = parseFloat(length.toString()) + + if (auto_length) { let w = parametric.length.min - const max_sections = Math.ceil(total_without_pillar / parametric.length.min) - const min_sections = Math.ceil(total_without_pillar / parametric.length.max) + const max_sections = Math.ceil(total_length_mm / (parametric.length.min + fence_length)) + const min_sections = Math.ceil(total_length_mm / (parametric.length.max + fence_length)) for (let index = min_sections; index <= max_sections; index++) { - w = (total_without_pillar / index) + form_state.fence_length + w = (total_length_mm - fence_length * (index - 1)) / index if (w >= parametric.length.min && w <= parametric.length.max) { break } } form_state.length = w + length = w } - const section_without_pillar = form_state.length - form_state.fence_length - - form_state.full_sections = Math.floor(total_without_pillar / section_without_pillar) - - if (section_without_pillar * form_state.full_sections !== form_state.full_sections) { - form_state.extra_section = Math.floor(total_without_pillar % section_without_pillar) + form_state.full_sections = Math.floor((total_length_mm - fence_length) / (length + fence_length)) + if (((form_state.full_sections * length) + (form_state.full_sections * fence_length) + fence_length) !== total_length_mm) { + form_state.extra_section = Math.floor((total_length_mm - fence_length) % form_state.length) } else { form_state.extra_section = 0 } @@ -135,7 +134,7 @@ const plurals = {