Point.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. using System.Text;
  5. namespace Dbscan
  6. {
  7. /// <summary>
  8. /// A point on the 2-d plane.
  9. /// </summary>
  10. /// <param name="X">The x-coordinate of the point.</param>
  11. /// <param name="Y">The y-coordinate of the point.</param>
  12. public struct Point : IEquatable<Point>
  13. {
  14. /// <summary>The x-coordinate of the point.</summary>
  15. public double X { get; set; }
  16. /// <summary>The y-coordinate of the point.</summary>
  17. public double Y { get; set; }
  18. /// <summary>
  19. /// A point on the 2-d plane.
  20. /// </summary>
  21. /// <param name="X">The x-coordinate of the point.</param>
  22. /// <param name="Y">The y-coordinate of the point.</param>
  23. public Point(double X, double Y)
  24. {
  25. this.X = X;
  26. this.Y = Y;
  27. }
  28. [CompilerGenerated]
  29. public override string ToString()
  30. {
  31. StringBuilder stringBuilder = new StringBuilder();
  32. stringBuilder.Append("Point");
  33. stringBuilder.Append(" { ");
  34. if (PrintMembers(stringBuilder))
  35. {
  36. stringBuilder.Append(' ');
  37. }
  38. stringBuilder.Append('}');
  39. return stringBuilder.ToString();
  40. }
  41. [CompilerGenerated]
  42. private bool PrintMembers(StringBuilder builder)
  43. {
  44. builder.Append("X = ");
  45. builder.Append(X.ToString());
  46. builder.Append(", Y = ");
  47. builder.Append(Y.ToString());
  48. return true;
  49. }
  50. [CompilerGenerated]
  51. public static bool operator !=(Point left, Point right)
  52. {
  53. return !(left == right);
  54. }
  55. [CompilerGenerated]
  56. public static bool operator ==(Point left, Point right)
  57. {
  58. return left.Equals(right);
  59. }
  60. [CompilerGenerated]
  61. public override int GetHashCode()
  62. {
  63. return EqualityComparer<double>.Default.GetHashCode(X) * -1521134295 + EqualityComparer<double>.Default.GetHashCode(Y);
  64. }
  65. [CompilerGenerated]
  66. public override bool Equals(object obj)
  67. {
  68. if (obj is Point)
  69. {
  70. return Equals((Point)obj);
  71. }
  72. return false;
  73. }
  74. [CompilerGenerated]
  75. public bool Equals(Point other)
  76. {
  77. if (EqualityComparer<double>.Default.Equals(X, other.X))
  78. {
  79. return EqualityComparer<double>.Default.Equals(Y, other.Y);
  80. }
  81. return false;
  82. }
  83. [CompilerGenerated]
  84. public void Deconstruct(out double X, out double Y)
  85. {
  86. X = this.X;
  87. Y = this.Y;
  88. }
  89. }
  90. public class Data : IPointData
  91. {
  92. public long ID { get; set; }
  93. public Point Point { get; set; }
  94. }
  95. }