IDS peak ICV v1.3.0
Loading...
Searching...
No Matches
PointXYZ.cs
Go to the documentation of this file.
1using System.Globalization;
2
4
10public class PointXYZ
11{
22 public PointXYZ(float x, float y, float z)
23 {
24 X = x;
25 Y = y;
26 Z = z;
27 }
28
33 public float X { get; set; }
34
39 public float Y { get; set; }
40
45 public float Z { get; set; }
46
51 public static IEqualityComparer<PointXYZ> Comparer { get; } = new PointXYZEqualityComparer();
52
59 public override string ToString()
60 {
61 return
62 $"{nameof(X)}: {X.ToString("0.0", CultureInfo.InvariantCulture)}, " +
63 $"{nameof(Y)}: {Y.ToString("0.0", CultureInfo.InvariantCulture)}, " +
64 $"{nameof(Z)}: {Z.ToString("0.0", CultureInfo.InvariantCulture)}";
65 }
66
67 private sealed class PointXYZEqualityComparer : IEqualityComparer<PointXYZ>
68 {
69 public bool Equals(PointXYZ x, PointXYZ y)
70 {
71 if (ReferenceEquals(x, y))
72 {
73 return true;
74 }
75
76 if (ReferenceEquals(x, null))
77 {
78 return false;
79 }
80
81 if (ReferenceEquals(y, null))
82 {
83 return false;
84 }
85
86 return x.X.Equals(y.X) && x.Y.Equals(y.Y) && x.Z.Equals(y.Z);
87 }
88
89 public int GetHashCode(PointXYZ obj)
90 {
91 return (obj.X, obj.Y, obj.Z).GetHashCode();
92 }
93 }
94}
A point consists of x, y and z coordinate.
Definition PointXYZ.cs:11
PointXYZ(float x, float y, float z)
Initializes a new instance of the PointXYZ class with specified coordinates.
Definition PointXYZ.cs:22
float Z
Gets or sets the Z coordinate of the point.
Definition PointXYZ.cs:45
override string ToString()
Returns a string representation of the point.
Definition PointXYZ.cs:59
float X
Gets or sets the X coordinate of the point.
Definition PointXYZ.cs:33
static IEqualityComparer< PointXYZ > Comparer
Gets a default equality comparer for comparing PointXYZ data values.
Definition PointXYZ.cs:51
float Y
Gets or sets the Y coordinate of the point.
Definition PointXYZ.cs:39