Pages

Angle Tester

class AngleTester
{
    private AngleTester() { throw new UnsupportedOperationException(); }
    private static void test4(Angle original, Angle transformed, String transformation)
    {
        System.out.print(transformation + ": ");
        System.out.print(transformed);
        System.out.print(". Coterminal? ");
        System.out.println(original.isCoterminalWith(transformed));
    }
    private static void test3(Angle a)
    {
        test4(a, a.toReducedAngle(), "Reduced Angle");
        test4(a, a.toReferenceAngle(), "Reference Angle");
        test4(a, a.toComplement(), "Complement");
        test4(a, a.toSupplement(), "Supplement");
    }
    private static void test2(Angle a)
    {
        System.out.print("\n" + a.toString() + " is ");
        Angle[] angles = {new Degrees(a), new Radians(a), new Zygo(a)};
        for(Angle angle : angles) System.out.print(angle.toString() + ", ");
        System.out.println("...");
        test3(a);
    }
    private static void test1(double val)
    {
        System.out.println("Value: " + val);
        Angle [] angles = {new Degrees(val), new Radians(val), new Zygo(val)};
        for (Angle a : angles) test2(a);
    }
    public static void test(double val)
    {
        test1(val);
        System.out.println();
    }
}

public class AngularMeasurements
{
    private AngularMeasurements() { throw new UnsupportedOperationException(); }
    public static void main(String[] args)
    {
        double tau = 2 * Math.PI;
        double rand = Math.random() * 10000 - 5000;
        double values[] = {-370, -3.6, 0, 3.6, tau, 90.0, 100, 180.0, 350, 360.0, 370.0, rand};
        for (double value : values) AngleTester.test(value);
    }
}