Here you can find the source of difference(final float from, final float to)
Parameter | Description |
---|---|
from | the origin angle in degrees |
to | the target angle in degrees |
public static float difference(final float from, final float to)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w w w . j av a 2 s . c o m*/ * Return the angle to turn of to go from an angle to the other * * @param from * the origin angle in degrees * @param to * the target angle in degrees * @return a value in degrees, in the [-180, 180[ range */ public static float difference(final float from, final float to) { return normalize(to - from + 180) - 180; } /** * Normalize an angle so that it belongs to the [0, 360[ range. * @param angle the angle in degrees * @return the same angle in the [0, 360[ range */ public static float normalize(final float angle) { return (angle >= 0 ? angle : (360 - ((-angle) % 360))) % 360; } }