Aura.Channel.World.Position.GetDistance C# (CSharp) Метод

GetDistance() публичный Метод

Returns distance between this and another position.
public GetDistance ( Position otherPos ) : int
otherPos Position
Результат int
		public int GetDistance(Position otherPos)
		{
			return (int)Math.Sqrt(Math.Pow(X - otherPos.X, 2) + Math.Pow(Y - otherPos.Y, 2));
		}

Usage Example

Пример #1
0
		public void GetDistance()
		{
			var pos1 = new Position(0, 0);
			var pos2 = new Position(0, 500);
			var pos3 = new Position(0, -500);
			var pos4 = new Position(500, 500);
			var pos5 = new Position(-500, -500);

			Assert.Equal(500, pos1.GetDistance(pos2));
			Assert.Equal(500, pos1.GetDistance(pos3));
			Assert.Equal(707, pos1.GetDistance(pos4));
			Assert.Equal(707, pos1.GetDistance(pos5));
			Assert.Equal(1414, pos4.GetDistance(pos5));
		}
All Usage Examples Of Aura.Channel.World.Position::GetDistance