app/src/main/java/com/geekyouup/android/ustopwatch/fragments/StopwatchCustomVectorView.java
//From 1 rads to 5 rads shortest distance is CCW back through 0 rads
From 1 rads to 5 rads shortest distance is CCW back through 0 rads
From 1 rads to 5 rads shortest distance is CCW back through 0 rads
private float shortestAngleToDestination(final float fromAngle, final float toAngle, boolean resetting) {
        if (resetting && mIsStopwatch) 
        {
            return toAngle; 
        } else if (resetting && !mIsStopwatch) 
        {
            if (toAngle > fromAngle) return toAngle;
            else return (toAngle + twoPI);
        } else 
        {
            float absFromMinusTo = Math.abs(fromAngle - toAngle);
            if (absFromMinusTo < Math.abs(fromAngle - (toAngle + twoPI))) {
                if (Math.abs(fromAngle - (toAngle - twoPI)) < absFromMinusTo) {
                    return (toAngle - twoPI);
                } else {
                    return toAngle;
                }
            } else return toAngle + twoPI;
        }
    }
private float shortestAngleToDestination ( final float fromAngle , final float toAngle , boolean resetting ) { if ( resetting && mIsStopwatch ) { return toAngle ; } else if ( resetting && ! mIsStopwatch ) { if ( toAngle > fromAngle ) return toAngle ; else return ( toAngle + twoPI ) ; } else { float absFromMinusTo = Math . abs ( fromAngle - toAngle ) ; if ( absFromMinusTo < Math . abs ( fromAngle - ( toAngle + twoPI ) ) ) { if ( Math . abs ( fromAngle - ( toAngle - twoPI ) ) < absFromMinusTo ) { return ( toAngle - twoPI ) ; } else { return toAngle ; } } else return toAngle + twoPI ; } }
From 1 rads to 5 rads shortest distance is CCW back through 0 rads
From 1 rads to 5 rads shortest distance is CCW back through 0 rads
// hands must always go backwards // stopwatch reset always returns to 0, //hands must always go forwards //countdown reset can be to any clock position, ensure CW rotation //not restting hands must take shortest route //toAngle-twoPi, toAngle, toAngle+twoPi