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!
