/** * Calculates a spin with which the given karttu will be at given angle when it lands. * * @param k karttu which desired spin should be calculated * @param angle angle at which the karttu should land * @return spin at which Karttu k will land at angle angle */ public static double calculateDesiredSpin(Karttu k, double angle) { int time = calculateLandingTime(k); double spin = (((angle - k.getAngle()) % 360 + 360) % 360) / time; return spin; }
/** * Calculates the angle given karttu will have when it lands. * * @param k karttu which landing angle to calculate * @return angle of landing */ public static double calculateLandingAngle(Karttu k) { int time = calculateLandingTime(k); double angle = k.getAngle() + k.getSpin() * time; angle %= 360; return angle; }