fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public class Vector2 {
  6. public double X;
  7. public double Y;
  8.  
  9. public Vector2(double X, double Y) {
  10. this.X = X;
  11. this.Y = Y;
  12. }
  13. }
  14.  
  15. private static bool IsInEclipse(Vector2 position, Vector2 center, Vector2 radius)
  16. {
  17. bool result = false;
  18.  
  19. var powResult =
  20. Math.Pow(position.X - center.X, 2.0d) / (radius.X * radius.X) +
  21. Math.Pow(position.Y - center.Y, 2.0d) / (radius.Y * radius.Y);
  22.  
  23. if (powResult <= 1)
  24. {
  25. result = true;
  26. }
  27.  
  28. return result;
  29. }
  30.  
  31. public static void Main()
  32. {
  33. Console.WriteLine(IsInEclipse(
  34. new Vector2(360, 640),
  35. new Vector2(683, 423),
  36. new Vector2(700, 460)
  37. ));
  38. }
  39. }
Success #stdin #stdout 0.02s 16020KB
stdin
Standard input is empty
stdout
True