Пример #1
0
    // Returns the larger distance between the two values.
    public static float GetLargerDistance(float value1, float value2, IntervalFloat interval)
    {
        float distance = GetSomeDistance(value1, value2, interval);

        if (distance <= interval.GetCenter())
        {
            return(interval.GetDiameter() - distance);
        }
        else
        {
            return(distance);
        }
    }
Пример #2
0
    // Returns true if the shortest path between the two given values can be
    // traversed by a positive increase from the start value.
    public static bool IsShortestRotationPositive(float start, float end,
                                                  IntervalFloat interval)
    {
        // Normalize the start and end values to be within the interval.
        start = MoveIntoInterval(start, interval);
        end   = MoveIntoInterval(end, interval);

        // Whether the shortest rotation involves stepping (wrapping)
        // across the ends of the interval.
        // True means it doesn't need to wrap. False means it does.
        bool wrapless = Mathf.Abs(start - end) < interval.GetCenter();

        if (start < end)
        {
            return(wrapless);
        }
        else
        {
            return(!wrapless);
        }
    }
Пример #3
0
 // Mirrors a value across the y-axis of a circle.
 public static float MirrorHorizontal(float value, IntervalFloat interval)
 {
     return(MoveIntoInterval(interval.GetCenter() - value, interval));
 }