IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
Point.cs
Go to the documentation of this file.
3
5{
6 namespace Detail
7 {
12
13 public class PointT<T>
14 {
20 public PointT(T x, T y)
21 {
22 X = x;
23 Y = y;
24 }
25
29 public T X { get; }
30
34 public T Y { get; }
35
41 public override bool Equals(object? obj)
42 {
43 if (obj is null)
44 {
45 return false;
46 }
47
48 if (ReferenceEquals(this, obj))
49 {
50 return true;
51 }
52
53 if (obj is not PointT<T> other)
54 {
55 return false;
56 }
57
58 return Equals(other);
59 }
60
66 protected bool Equals(PointT<T> other)
67 {
68 return X != null && X.Equals(other.X) && Y != null && Y.Equals(other.Y);
69 }
70
74 public override int GetHashCode()
75 {
76 return (X, Y).GetHashCode();
77 }
78
83 public override string ToString()
84 {
85 return Formatting.Invariant($"{GetType().Name}{{ {nameof(X)} = {X}, {nameof(Y)} = {Y} }}");
86 }
87 }
88 }
89
93
97 public class Point : PointT<int>
98 {
102 public Point()
103 : base(0, 0)
104 {
105 }
106
112 public Point(int x, int y)
113 : base(x, y)
114 {
115 }
116 }
117
121
125 public class PointF : PointT<float>
126 {
130 public PointF()
131 : base(0.0f, 0.0f)
132 {
133 }
134
140 public PointF(float x, float y)
141 : base(x, y)
142 {
143 }
144 }
145
149
153 public class PointU : PointT<uint>
154 {
158 public PointU()
159 : base(0, 0)
160 {
161 }
162
168 public PointU(uint x, uint y)
169 : base(x, y)
170 {
171 }
172 }
173
177
181 public class VectorF : PointF
182 {
186 public VectorF()
187 : base(0.0f, 0.0f)
188 {
189 }
190
196 public VectorF(float x, float y)
197 : base(x, y)
198 {
199 }
200 }
201}
Represents a 2D point with generic coordinates.
Definition Point.cs:14
override int GetHashCode()
Returns a hash code for the current point.
Definition Point.cs:74
override bool Equals(object? obj)
Determines whether the specified object is equal to the current PointT<T>.
Definition Point.cs:41
PointT(T x, T y)
Initializes a new instance of the PointT<T> class with specified coordinates.
Definition Point.cs:20
override string ToString()
Converts the PointT<T> to a string representation.
Definition Point.cs:83
T Y
Gets the Y coordinate of the point.
Definition Point.cs:34
T X
Gets the X coordinate of the point.
Definition Point.cs:29
Represents a 2D point with floating-point coordinates.
Definition Point.cs:126
PointF(float x, float y)
Initializes a new instance of the PointF class with specified floating-point coordinates.
Definition Point.cs:140
PointF()
Initializes a new instance of the PointF class with default coordinates (0.0f, 0.0f).
Definition Point.cs:130
Represents a 2D point with integer coordinates.
Definition Point.cs:98
Point(int x, int y)
Initializes a new instance of the Point class with specified integer coordinates.
Definition Point.cs:112
Point()
Initializes a new instance of the Point class with default coordinates (0, 0).
Definition Point.cs:102
Represents a 2D point with unsigned integer coordinates.
Definition Point.cs:154
PointU(uint x, uint y)
Initializes a new instance of the PointU class with specified integer coordinates.
Definition Point.cs:168
PointU()
Initializes a new instance of the PointU class with default coordinates (0, 0).
Definition Point.cs:158
Represents a 2D vector with floating-point values.
Definition Point.cs:182
VectorF()
Initializes a new instance of the VectorF class with default coordinates (0.0f, 0....
Definition Point.cs:186
VectorF(float x, float y)
Initializes a new instance of the VectorF class with specified floating-point coordinates.
Definition Point.cs:196