Java Angle angleInRange(float theta1, float theta2, float tolerance)

Here you can find the source of angleInRange(float theta1, float theta2, float tolerance)

Description

angle In Range

License

Open Source License

Declaration

public static boolean angleInRange(float theta1, float theta2, float tolerance) 

Method Source Code

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

public class Main {
    public static boolean angleInRange(float theta1, float theta2, float tolerance) {
        theta1 = boundAngle(theta1);//from   w  ww .  j  ava 2  s .c o  m
        theta2 = boundAngle(theta2);
        float dtheta = Math.abs(theta1 - theta2);

        if (dtheta > Math.PI) {
            if (2 * Math.PI - dtheta <= tolerance)
                return true;
        } else {
            if (dtheta <= tolerance)
                return true;
        }

        return false;
    }

    public static float boundAngle(float theta) {
        theta /= Math.PI;
        theta = (theta + 1) / 2;
        if (theta > 1 || theta < 0)
            theta -= (int) (theta);
        theta = theta * 2 - 1;
        return theta * (float) Math.PI;
    }
}

Related

  1. angleFromDirection(float dirX, float dirY)
  2. angleFromR(final double[][] R)
  3. angleInDegrees(float ownerRotation, float x1, float y1, float x2, float y2)
  4. angleInRadians(float originX, float originY, float targetX, float targetY)
  5. angleInRange(double angle, double min, double max)
  6. angleLinear(float a, float b, int spin, float f)
  7. angleOfLine(int x1, int y1, int x2, int y2)
  8. angleOfLineDeg(double x1, double y1, double x2, double y2)
  9. angleRadToDegClipped(final double angleRad)