View Single Post
Old 08-06-2008, 12:56 PM   #1 (permalink)
vermillion2083
Forum Expert
 
vermillion2083's Avatar
 
Join Date: Jun 2005
Location: Lansing, MI
Age: 25
Posts: 1,042
Send a message via ICQ to vermillion2083 Send a message via MSN to vermillion2083
Default Finding the distance between two mobiles

Good afternoon all,

The distance between two mobiles has been a value that I have found myself needing several times in the past, so I figured its due time I figured it out. I made an attempt using the Pythagorean Theorem but I am not entirely sure if this will function or not (I am at work so I am unable to test it). I've seen several users show their amazing capabilities with mathematic formulas here on the RunUO forums, so I figured I would post my first attempt in hopes that someone will be able to either confirm that this method will function, or lead me in a better direction.

Code:
	public static int CalculateDistance( Mobile from, Mobile target )
	{
		int distance = Math.Sqrt( Math.Pow( from.X - from.Y, 2 ) + Math.Pow( target.X - target.Y, 2 ) );
		return distance;
	}
The formula I was attempting to follow (although it has been so long since I’ve taken a math class only god know how far off I am) can be found here:

The Distance Formula

Any assistance with this method would be greatly appreciated. Thank you all in advance!
__________________
Father Time
Life's journey is not to arrive at the grave safely in a well preserved body, but rather to skid in sideways, totally worn out, shouting "Holy Hell......What a ride!!!"

Server: UO: Extinction
ICQ: 146563794
FatherTime@UOExtinction.com
UO: Extinction homepage
UO: Extinction forum
vermillion2083 is offline   Reply With Quote