package com.gmail.woodyc40.commons.providers;

import java.util.HashMap;
import java.util.Map;

/**
 * Faster hashtable look ups for trig functions sin, cos, and tan
 *
 * @author AgentTroll
 * @version 1.0
 */
public class TrigProvider {
    /**
     * Sin values
     */
    private static final Map<Double, Double> sin = new HashMap<>();
    /**
     * Cosine values
     */
    private static final Map<Double, Double> cos = new HashMap<>();
    /**
     * Tangent values
     */
    private static final Map<Double, Double> tan = new HashMap<>();

    static {
        for (int temp = 0; temp <= 36000; temp++) {
            double d = temp / 100;
            sin.put(Double.valueOf(d), Double.valueOf(Math.sin(d)));
            cos.put(Double.valueOf(d), Double.valueOf(Math.cos(d)));
            tan.put(Double.valueOf(d), Double.valueOf(Math.tan(d)));
        }
    }

    /**
     * Executes lookup for sine of value
     *
     * @param val the value to sin for
     * @return the sine of val
     */
    public static double sin(double val) {
        double ret = 0.0;
        ret = sin.get(Double.valueOf(val));
        return ret;
    }

    /**
     * Executes lookup for tangent of value
     *
     * @param val the value to tan for
     * @return the tangent of val
     */
    public static double cos(double val) {
        double ret = 0.0;
        ret = cos.get(Double.valueOf(val));
        return ret;
    }

    /**
     * Executes lookup for cosine of value
     *
     * @param val the value to cos for
     * @return the cosine of val
     */
    public static double tan(double val) {
        double ret = 0.0;
        ret = tan.get(Double.valueOf(val));
        return ret;
    }
}

@@ -1,8 +1,786 @@
+/*%0A * This file is part of BukkitCommons.%0A *%0A * Copyright (C) 2014 AgentTroll%0A *%0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 2 of the License, or%0A * (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A *%0A * You should have received a copy of the GNU General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A *%0A * Contact: woodyc40 (at) gmail (dot) com%0A */%0A %0A
 package 

Update TrigProvider.java