-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathVector3.cs
90 lines (81 loc) · 2.96 KB
/
Vector3.cs
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
using JetBrains.Annotations;
using System.ComponentModel.DataAnnotations;
namespace NFive.SDK.Core.Models
{
/// <summary>
/// Represents a position in 3D space.
/// </summary>
[PublicAPI]
public class Vector3 : Vector2
{
/// <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="Vector3" /> class.
/// </summary>
public Vector3() { }
/// <summary>
/// Initializes a new instance of the <see cref="Vector3" /> 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 Vector3(float x, float y, float z) : base(x, 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="Vector3" />, is equal to this instance.
/// </summary>
/// <param name="pos">The <see cref="Vector3" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="Vector3" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
protected bool Equals(Vector3 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((Vector3)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 Vectors have the same value.</summary>
/// <seealso cref="operator!=" />
/// <seealso cref="Equals" />
public static bool operator ==(Vector3 a, Vector3 b)
{
if ((object)a == null) return (object)b == null;
return a.Equals(b);
}
/// <summary>This method determines whether two Vectors do not have the same value.</summary>
/// <seealso cref="operator==" />
/// <seealso cref="Equals" />
public static bool operator !=(Vector3 a, Vector3 b) => !(a == b);
}
}