// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; namespace osu.Game.Rulesets.Difficulty.Utils { public static class DifficultyCalculationUtils { /// /// Converts BPM value into milliseconds /// /// Beats per minute /// Which rhythm delimiter to use, default is 1/4 /// BPM conveted to milliseconds public static double BPMToMilliseconds(double bpm, int delimiter = 4) { return 60000.0 / delimiter / bpm; } /// /// Converts milliseconds value into a BPM value /// /// Milliseconds /// Which rhythm delimiter to use, default is 1/4 /// Milliseconds conveted to beats per minute public static double MillisecondsToBPM(double ms, int delimiter = 4) { return 60000.0 / (ms * delimiter); } /// /// Calculates a S-shaped logistic function (https://en.wikipedia.org/wiki/Logistic_function) /// /// Value to calculate the function for /// Maximum value returnable by the function /// Growth rate of the function /// How much the function midpoint is offset from zero /// The output of logistic function of public static double Logistic(double x, double midpointOffset, double multiplier, double maxValue = 1) => maxValue / (1 + Math.Exp(multiplier * (midpointOffset - x))); /// /// Calculates a S-shaped logistic function (https://en.wikipedia.org/wiki/Logistic_function) /// /// Maximum value returnable by the function /// Exponent /// The output of logistic function public static double Logistic(double exponent, double maxValue = 1) => maxValue / (1 + Math.Exp(exponent)); } }