Java Float Number Clamp clamp180(float r1, float r2)

Here you can find the source of clamp180(float r1, float r2)

Description

clamp

License

Open Source License

Declaration

public static float clamp180(float r1, float r2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static float clamp180(float r1, float r2) {
        return clamp180(r1, r2, 0);
    }//from  w  w  w.  j a v a  2  s. c o  m

    public static float clamp180(float r1, float r2, float var3) {
        float dr = r2 - r1;
        while (dr < -180.0F) {
            dr += 360.0F;
        }

        while (dr >= 180.0F)
            dr -= 360.0F;
        if (dr > var3)
            dr = var3;
        if (dr < -var3)
            dr = -var3;

        return r1 + dr;
    }
}

Related

  1. clamp(float value, float min, float max)
  2. clamp(float value, float minimum, float maximum)
  3. clamp(float value, float minimum, float maximum)
  4. clamp(float x, float a, float b)
  5. clamp(float x, float y, float z)
  6. clamp1f(float f)
  7. clamp360(float dir)
  8. clamp_float(float p_76131_0_, float p_76131_1_, float p_76131_2_)
  9. clampAngle(float value, float min, float max)