public static float IdealAge(AthleteSex ASex, float dist) { if (Wava.list == null) { Wava.list = WavaTable(); } int sex = 1; if (ASex == AthleteSex.Female) { sex = 0; } int dlow = lowDistIndex(dist); if (Math.Abs(dist - aDist[dlow + 1]) < Math.Abs(dist - aDist[dlow])) { dlow++; } int alow = 0; for (int i = 1; i <= maxAge - minAge; i++) { if (Wava.list[sex, i, dlow] < Wava.list[sex, alow, dlow]) { alow=i; } } return alow + minAge; }
public static float IdealTime(AthleteSex ASex, float dist, float age) { if (Wava.list == null) { Wava.list = WavaTable(); } //The array is "complete" - otherwise there have to be some interpolations int sex = 1; if (ASex == AthleteSex.Female) { sex = 0; } int alow = (int)age - minAge; if (alow < 0) { alow = 0; } int maxIndex = maxAge - minAge - 1; if (alow > maxIndex) { alow = maxIndex; } int dlow = lowDistIndex(dist); float af = (age - alow - minAge); //high-low diff always 1 float df = (dist - aDist[dlow]) / (aDist[dlow + 1] - aDist[dlow]); float time = (1 - af) * (1 - df) * Wava.list[sex, alow + 0, dlow + 0] + (1 - af) * (0 + df) * Wava.list[sex, alow + 0, dlow + 1] + (0 + af) * (1 - df) * Wava.list[sex, alow + 1, dlow + 0] + (0 + af) * (0 + df) * Wava.list[sex, alow + 1, dlow + 1]; return time; }
public static void SetAgeSexFromActivity(IActivity act) { Predict.Sex = Plugin.GetApplication().Logbook.Athlete.Sex; DateTime d; if (act == null) { d = DateTime.Now; } else { d = act.StartTime; } float age = (float)(d - Plugin.GetApplication().Logbook.Athlete.DateOfBirth).TotalDays / 365.24f; if (!float.IsNaN(age)) { Predict.CurrentAge = age; } }