d9ffda81f04af3dd1626ef679eaf0eacba550381
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Point3D.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// The Point3D is a Struct that defining a 3-D point.
23     /// </summary>
24     /// <since_tizen> preview </since_tizen>
25     public struct Point3D : IEquatable<Point3D>
26     {
27         /// <summary>
28         /// The X coordinate of a 3D point.
29         /// </summary>
30         /// <since_tizen> preview </since_tizen>
31         public int X;
32
33         /// <summary>
34         /// The Y coordinate of a 3D point.
35         /// </summary>
36         /// <since_tizen> preview </since_tizen>
37         public int Y;
38
39         /// <summary>
40         /// The Z coordinate of a 3D point.
41         /// </summary>
42         /// <since_tizen> preview </since_tizen>
43         public int Z;
44
45         /// <summary>
46         /// A human-readable representation of the <see cref="T:Tizen.UI.Point3D" />.
47         /// </summary>
48         /// <returns>The string is formatted as "{{X={0} Y={1} Z={2}}}".</returns>
49         /// <since_tizen> preview </since_tizen>
50         public override string ToString()
51         {
52             return string.Format("{{X={0} Y={1} Z={2}}}", X, Y, Z);
53         }
54
55         ///
56         /// <since_tizen> preview </since_tizen>
57         public override int GetHashCode()
58         {
59             unchecked
60             {
61                 int hashCode = X.GetHashCode();
62                 hashCode = (hashCode * 397) ^ Y.GetHashCode();
63                 hashCode = (hashCode * 397) ^ Z.GetHashCode();
64                 return hashCode;
65             }
66         }
67
68         /// <summary>
69         /// Indicates whether this instance and a specified object are equal.
70         /// </summary>
71         /// <param name="obj">The object to compare with the current instance.</param>
72         /// <returns>
73         /// true if obj and this instance are the same type and represent the same value.
74         /// otherwise, false.
75         /// </returns>
76         /// <since_tizen> preview </since_tizen>
77         public override bool Equals(object obj)
78         {
79             if (!(obj is Point3D))
80                 return false;
81
82             return Equals((Point3D)obj);
83         }
84
85         /// <summary>
86         /// Indicates whether this instance and a <see cref="Point3D"/> object are equal.
87         /// </summary>
88         /// <param name="other">The <see cref="Point3D"/> to compare with the current instance.</param>
89         /// <returns>
90         /// true if obj and this instance are the same type and represent the same value.
91         /// otherwise, false.
92         /// </returns>
93         /// <since_tizen> preview </since_tizen>
94         public bool Equals(Point3D other)
95         {
96             return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z);
97         }
98
99         /// <summary>
100         /// Whether the two <see cref="T:Tizen.UI.Point3D" />s are equal.
101         /// </summary>
102         /// <param name="p1">A <see cref="T:Tizen.UI.Point3D" /> on the left hand side.</param>
103         /// <param name="p2">A <see cref="T:Tizen.UI.Point3D" /> on the right hand side.</param>
104         /// <returns>True if the two <see cref="T:Tizen.UI.Point3D" />s have equal values.</returns>
105         /// <since_tizen> preview </since_tizen>
106         public static bool operator ==(Point3D p1, Point3D p2)
107         {
108             return p1.Equals(p2);
109         }
110
111         /// <summary>
112         /// Whether two <see cref="T:Tizen.UI.Point3D" />s are not equal.
113         /// </summary>
114         /// <param name="p1">A <see cref="T:Tizen.UI.Point3D" /> on the left hand side.</param>
115         /// <param name="p2">A <see cref="T:Tizen.UI.Point3D" /> on the right hand side.</param>
116         /// <returns>True if the two <see cref="T:Tizen.UI.Point3D" />s do not have equal values.</returns>
117         /// <since_tizen> preview </since_tizen>
118         public static bool operator !=(Point3D p1, Point3D p2)
119         {
120             return !p1.Equals(p2);
121         }
122     }
123 }