Here you can find the source of interpolateAngle(double oldAngle, double newAngle, double scale)
Parameter | Description |
---|---|
oldAngle | the previous angle. |
newAngle | the new angle. |
scale | the relative angle between oldAngle (0%) and newAngle (100%). |
public static double interpolateAngle(double oldAngle, double newAngle, double scale)
//package com.java2s; /*//w w w . j a v a2 s . c o m * @(#) CourseUtils.java * * This code is part of the JAviator project: javiator.cs.uni-salzburg.at * Copyright (c) 2009 Clemens Krainer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ public class Main { /** * Interpolate between two angles. This method is only visible within this * package. * * @param oldAngle the previous angle. * @param newAngle the new angle. * @param scale the relative angle between oldAngle (0%) and newAngle (100%). * @return the interpolated angle. */ public static double interpolateAngle(double oldAngle, double newAngle, double scale) { while (newAngle - oldAngle > 360) newAngle -= 360; while (newAngle - oldAngle < -360) newAngle += 360; double result = oldAngle + (newAngle - oldAngle) * scale; while (result < 0) result += 360; while (result >= 360) result -= 360; return result; } }