public double GetAngleTo(Unit unit) { return GetAngleTo(unit.x, unit.y); }
public double GetSpeed(Unit u) { return Math.Sqrt(u.SpeedX * u.SpeedX + u.SpeedY * u.SpeedY); }
public double GetDistanceTo(Unit unit) { return GetDistanceTo(unit.x, unit.y); }
public static Cell GetCell(Unit p) { return GetCell(p.X, p.Y); }
public double GetAngleTo(Unit unit) { return GetAngleTo(unit.X, unit.Y); }
public void GoTo(Unit self, double tX, double tY, double tSpeedX, double tSpeedY, out double power, out double turn) { double Rx = self.X - tX; double Ry = self.Y - tY; double Vx = self.SpeedX - tSpeedX; double Vy = self.SpeedY - tSpeedY; double t = (Vx * Vx + Vy * Vy) / (Vx * Vx + Vy * Vy + Rx * Rx + Ry * Ry); double Ax = -Rx * (1 - t) - Vx * t; double Ay = -Ry * (1 - t) - Vy * t; power = Math.Cos(GetAngleBetween(0, 0, Ax, Ay, self.Angle)) * Math.Sqrt(Ax * Ax + Ay * Ay); double Frw = GetAngleBetween(0, 0, Ax, Ay, self.Angle); double Bck = GetAngleBetween(0, 0, -Ax, -Ay, self.Angle); if (Math.Abs(Frw) < Math.Abs(Bck) + Math.PI / 18.0D) turn = Frw; else turn = -Bck; }
public void GoTo(Unit self, Unit target, out double power, out double turn) { GoTo(self, target.X, target.Y, target.SpeedX, target.SpeedY, out power, out turn); }
public double GetDistance(double X, double Y, Unit U) { return GetDistance(U.X, U.Y, X, Y); }