public InterpolationResults(float height, float initWeight, float dream_weight, float age, string gender, string activity, float waist, float hips, float neck, bool hardMode) { // Отображение введенных показателей InputHeight = height.ToString(); InputWeight = initWeight.ToString(); InputAge = age.ToString(); InputGender = gender.ToString(); InputActivity = activity.ToString(); InputDreamWeight = dream_weight == 0 ? "" : dream_weight.ToString(); // Пол Gender genderValue = GenderDict[gender]; // Отнесение человека к одной из 6 категорий по половозрастноым признакам AgeGenderClassification selectedCategory = SelectCategory(genderValue, age); // Расчет распределения зон телосложения, результирущих показателей % жировой ткани, веса и кол-ва недель var results = CalcSchedule(height, initWeight, dream_weight, age, genderValue, activity, waist, hips, neck, hardMode); // График распределения зон телосложений ScheduleValues = results.Item1; // Получаем словарь со списками распределения графика похудения по типам телосложения _bodyTypeZonesDict = GetBodyZonesDictionary(height, initWeight, dream_weight, waist, hips, neck, genderValue, selectedCategory, hardMode); // Масса на границе начала зоны истощения LimitWeight = GetLimitWeight(_bodyTypeZonesDict[BodyType.thin]); // Критическая масса тела (несовместимая с жизнью) CriticalWeight = GetCriticalWeight(genderValue, results.Item2, results.Item3); // Кол-во недель в плане WeeksCount = results.Item4.ToString(); // Рекомендации Recomendations = GetWarning(LimitWeight, CriticalWeight); // Распределение веса в зависимости от недель (для каждой зоны телосложения отдельная зависимость) Distribution = GetInterpltnDistribution(ResultDict, _bodyTypeZonesDict); // Фокус на график Anchor = "charts"; }
private (ScheduleValues, float, float, int) CalcSchedule(float height, float initWeight, float dream_weight, float age, Gender gender, string activity, float waist, float hips, float neck, bool hardMode) { ScheduleValues scheduleValues = new ScheduleValues(); float weight = 0; float fatPercent = 0; float fatPercentDifference = 0; int week = 0; do { float kkal; float protein; float fat; float carbohydrate; // Период и Дата scheduleValues.WeeksValues.Add(week); scheduleValues.Date.Add(DateTime.Now.AddDays(week * 7).ToString("dd/MM/yy", CultureInfo.InvariantCulture)); // Вес и %жировой ткани if (week == 0) { // Начальный вес weight = initWeight; // Расчет % жировой ткани var res = CalcFatPercent(height, weight, gender, waist, hips, neck, hardMode); fatPercent = res.Item1; fatPercentDifference = res.Item2; // Расчет нормы калорий для поддержания веса kkal = KbguCalculation.GetKBGU(weight, height, age, gender, ActivityDict[activity])[0]; } else { // Пересчет веса weight = (1 - KbguCalculation.GetWeightRecession(fatPercent, gender)) * weight; // Персчет % жировой ткани fatPercent = KbguCalculation.FatPercent(height, weight, gender) + fatPercentDifference; // Пересчет калорий var recession = 1 - KbguCalculation.GetKBGUrecession(fatPercent, gender); kkal = recession * KbguCalculation.GetKBGU(weight, height, age, gender, ActivityDict[activity])[0]; } scheduleValues.WeightValues.Add((float)Math.Round(weight, 2)); scheduleValues.FatPercentValues.Add((float)Math.Round(fatPercent, 2)); // Норма БЖУ protein = KbguCalculation.GetKBGU(weight, height, age, gender, ActivityDict[activity])[1]; fat = KbguCalculation.GetKBGU(weight, height, age, gender, ActivityDict[activity])[2]; carbohydrate = KbguCalculation.GetKBGU(weight, height, age, gender, ActivityDict[activity])[3]; scheduleValues.KkalValues.Add((int)Math.Round(kkal)); scheduleValues.ProteinValues.Add((int)Math.Round(protein)); scheduleValues.FatValues.Add((int)Math.Round(fat)); scheduleValues.CarbongydrateValues.Add((int)Math.Round(carbohydrate)); week++; }while (!IsCriticalFatValue(gender, fatPercent) && weight > dream_weight); return(scheduleValues, fatPercent, weight, week); }