-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPosition.cs
More file actions
112 lines (101 loc) · 3.42 KB
/
Copy pathPosition.cs
File metadata and controls
112 lines (101 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using JetBrains.Annotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace NFive.SDK.Core.Models
{
/// <summary>
/// Represents a position in 3D space.
/// </summary>
[PublicAPI]
[ComplexType]
public class Position
{
/// <summary>
/// Gets or sets the position on the X axis.
/// </summary>
/// <value>
/// The position on the X axis.
/// </value>
[Required]
public float X { get; set; }
/// <summary>
/// Gets or sets the position on the Y axis.
/// </summary>
/// <value>
/// The position on the Y axis.
/// </value>
[Required]
public float Y { get; set; }
/// <summary>
/// Gets or sets the position on the Z axis.
/// </summary>
/// <value>
/// The position on the Z axis.
/// </value>
[Required]
public float Z { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Position" /> class.
/// </summary>
public Position() { }
/// <summary>
/// Initializes a new instance of the <see cref="Position" /> class.
/// </summary>
/// <param name="x">The position on the X axis.</param>
/// <param name="y">The position on the Y axis.</param>
/// <param name="z">The position on the Z axis.</param>
public Position(float x, float y, float z)
{
this.X = x;
this.Y = y;
this.Z = z;
}
/// <summary>
/// Returns a <see cref="string" /> that represents this position.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this position.
/// </returns>
public override string ToString() => $"X: {this.X}, Y: {this.Y}, Z: {this.Z}";
/// <summary>
/// Determines whether the specified <see cref="Position" />, is equal to this instance.
/// </summary>
/// <param name="pos">The <see cref="Position" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="Position" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
protected bool Equals(Position pos) => this.X.Equals(pos.X) && this.Y.Equals(pos.Y) && this.Z.Equals(pos.Z);
/// <summary>
/// Determines whether the specified <see cref="object" />, is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals((Position)obj);
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode() => ToString().GetHashCode();
/// <summary>This method determines whether two Positions have the same value.</summary>
/// <seealso cref="operator!=" />
/// <seealso cref="Equals" />
public static bool operator ==(Position a, Position b)
{
if ((object)a == null) return (object)b == null;
return a.Equals(b);
}
/// <summary>This method determines whether two Positions do not have the same value.</summary>
/// <seealso cref="operator==" />
/// <seealso cref="Equals" />
public static bool operator !=(Position a, Position b) => !(a == b);
}
}