org.moyoman.util
Class Sqrt

java.lang.Object
  |
  +--org.moyoman.util.Sqrt

public class Sqrt
extends Object

This class is used as a fast means of getting the square roots of short values. The caller of this class will use it for converting a value which is the square of the distance between two stones into its actual value. For this reason, The largest possible value for a 19 x 19 board is 648.


Field Summary
private static short MAX
           
private static double[] values
           
 
Constructor Summary
Sqrt()
           
 
Method Summary
static double getSqrt(short i)
          Get the square root of the value.
static double getSqrt(short i, short j)
          Get the square root of (i * i) + (j * j).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX

private static short MAX

values

private static double[] values
Constructor Detail

Sqrt

public Sqrt()
Method Detail

getSqrt

public static double getSqrt(short i)
                      throws IndexOutOfBoundsException
Get the square root of the value.

Parameters:
i - The short value.
Returns:
A double which is the square root.
Throws:
IndexOutOfBoundsException - Thrown if the short is not \ in the range 0 - 648.

getSqrt

public static double getSqrt(short i,
                             short j)
                      throws IndexOutOfBoundsException
Get the square root of (i * i) + (j * j).

Parameters:
i - One short value.
j - Another short value.
Returns:
A double which is the square root.
Throws:
IndexOutOfBoundsException - Thrown if the short is not \ in the range 0 - 648.