Java algorithm for calculating closest point

I am trying to write an algorithm for calculating nearest point. Given: 3 cell phone towers, 1 cell phone. Calculate which tower is closer to cell phone at any point/time. Please remember that cell phone is moving.Any help would be appreciated.
[265 byte] By [mlukowit@yahoo.coma] at [2007-11-26 21:53:33]
# 1
What part are you having trouble with?
jverda at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 2
> ...> Any help would be appreciated.With what exactly?
prometheuzza at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 3
Caluculating a moving object. I know I can set static points.
mlukowit@yahoo.coma at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 4
Is the distance from the phoneto a certain tower known? Or do you need to calculate that aswell?Message was edited by: johan.g
johan.ga at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 5
The distance needs to be calculated as well.
mlukowit@yahoo.coma at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 6

You need the distance formula

sqrt(a*a + b*b)

Check out my mathUtils class. I have distance already implemented

/*

* Created on Nov 7, 2004 by @author Tom Jacobs

*

*/

package tjacobs;

import java.awt.Point;

/**

* Simple math routines spelled out. There's euclideanDistance, factorial,

* combinations, distance.

*

* Pretty standard really.

*/

public class MathUtils {

private MathUtils() {

super();

}

public static double euclideanDistance(Point p1, Point p2) {

return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));

}

public static int factorial(int x) {

int pow = 1;

while (x > 1) {

pow = pow * x;

x--;

}

return pow;

}

public static int getCombinations(int total, int picks, boolean replacing, boolean ordered) {

int ans = 0;

if (replacing && ordered) {

ans = (int)Math.pow(total, picks);

//total / Math.pow(totalpicks)

}

else if (!replacing && ordered){

ans = factorial (total);

ans /= factorial(total - picks);

} else if (replacing && !ordered) {

ans = factorial(total + picks - 1);

ans /= factorial(picks);

ans /= factorial(total - picks);

}

else if (!replacing && !ordered) {

ans = factorial(total);

ans/= factorial(picks);

ans/= factorial(total - picks);

}

return ans;

}

public static double distance (Point p1, Point p2) {

return distance(p1.x, p1.y, p2.x, p2.y);

}

public static double distance(double x1, double y1) {

return distance(x1, y1, 0, 0);

}

public static double distance (double x1, double y1, double x2, double y2) {

return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

}

public static double angle (Point p1, Point p2) {

return angle(p1.x, p1.y, p2.x, p2.y);

}

public static double angle (double x1, double y1, double x2, double y2) {

double xdiff = x1 - x2;

double ydiff = y1 - y2;

double tan = xdiff / ydiff;

double atan = Math.atan2(ydiff, xdiff);

return atan;

}

public static double reflectOff(double ray, double reflectOff) {

return reflectOff + reflectOff - ray;

}

//Testing only

/*public static void main(String args[]) {

System.out.println(reflectOff(0, Math.PI / 4) / Math.PI);

System.out.println(reflectOff(Math.PI / 2, Math.PI) / Math.PI);

System.out.println(reflectOff(5 * Math.PI / 4, Math.PI / 2) / Math.PI);

System.out.println(reflectOff(Math.PI, Math.PI / 2));

}

*/

}

tjacobs01a at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 7
> Caluculating a moving object. I know I can set> static points.Am I missing something? Calculate the distance to each tower after a couple of seconds to see which one is closest.
prometheuzza at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 8
This has got to be about the most poorly communicated problem statement I've ever seen.
jverda at 2007-7-10 3:47:51 > top of Java-index,Java Essentials,Java Programming...
# 9
Correct.
mlukowit@yahoo.coma at 2007-7-10 3:47:52 > top of Java-index,Java Essentials,Java Programming...
# 10
> Correct.I'm glad you agree with jverd because from your OP I don't have a clue what input information is available on which to base any decision as to which is the closest tower.
sabre150a at 2007-7-10 3:47:52 > top of Java-index,Java Essentials,Java Programming...