e7c72a9852dec8081b82e138d2b8c03f3e68edaf
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / Position.cs
1 namespace Dali
2 {
3   using System;
4
5   public class Position
6   {
7
8     private float x;
9     private float y;
10     private float z;
11
12     /**
13      * @brief constructor
14      *
15      * @since 1.0.0
16      */
17     public Position()
18     {
19       x = 0.0f;
20       y = 0.0f;
21       z = 0.0f;
22     }
23
24     /**
25      * @brief constructor
26      *
27      * @since 1.0.0
28      * @param [in] a The Position X.
29      * @param [in] b The Position Y.
30      * @param [in] c The Position Z.
31      */
32     public Position(float a, float b, float c)
33     {
34       x = a;
35       y = b;
36       z = c;
37     }
38
39     /**
40      * @brief constructor
41      *
42      * @since 1.0.0
43      * @param [in] o The Vector Position X, Y, Z.
44      */
45     public Position(Vector3 o)
46     {
47       x = o.X;
48       y = o.Y;
49       z = o.Z;
50     }
51
52     ///< name "X", type float (Position X value)
53     //@since 1.0.0
54     public float X
55     {
56       get { return x; }
57       set { x = value; }
58     }
59
60     ///< name "Y", type float (Position Y value)
61     //@since 1.0.0
62     public float Y
63     {
64       get { return y; }
65       set { y = value; }
66     }
67
68     ///< name "Z", type float (Position Z value)
69     //@since 1.0.0
70     public float Z
71     {
72       get { return z; }
73       set { z = value; }
74     }
75
76     /**
77      * @brief operator+
78      *
79      * @since 1.0.0
80      * @param [in] l The Position to add.
81      * @param [in] r The Position to add
82      * @return A reference to this
83      */
84     public static Position operator +(Position l, Position r)
85     {
86       return new Position(l.X + r.X, l.Y + r.Y, l.Z + r.Z);
87     }
88
89     /**
90      * @brief operator-
91      *
92      * @since 1.0.0
93      * @param [in] l The Position to substract.
94      * @param [in] r The Position to substract
95      * @return A reference to this
96      */
97     public static Position operator -(Position l, Position r)
98     {
99       return new Position(l.X - r.X, l.Y - r.Y, l.Z - r.Z);
100     }
101
102     /**
103      * @brief operator*
104      *
105      * @since 1.0.0
106      * @param [in] a The Position to multiply.
107      * @param [in] b The constant to multiply of type double.
108      * @return A reference to this
109      */
110     public static Position operator *(Position a, double b)
111     {
112       return new Position((int)(a.X * b), (int)(a.Y * b), (int)(a.Z * b));
113     }
114
115     /**
116      * @brief operator/
117      *
118      * @since 1.0.0
119      * @param [in] a The Position to divide.
120      * @param [in] b The Position to divide
121      * @return float value of division operation
122      */
123     public static float operator /(Position a, Position b)
124     {
125       return (float)System.Math.Sqrt((a.X / b.X) * (a.Y / b.Y) * (a.Z / b.Z));
126     }
127
128     /**
129      * @brief Operator ==
130      *
131      * @since 1.0.0
132      * @param [in] a The Position object to compare.
133      * @param [in] b The Position object to compare.
134      * @return bool, whether Position are equal or not
135      */
136     public static bool operator == (Position a, Position b)
137     {
138       return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
139     }
140
141     /**
142      * @brief Operator !=
143      *
144      * @since 1.0.0
145      * @param [in] a The Position object to compare.
146      * @param [in] b The Position object to compare.
147      * @return bool, whether Position are equal or not
148      */
149     public static bool operator != (Position a, Position b)
150     {
151       return a.X != b.X || a.Y != b.Y || a.Z == b.Z;
152     }
153
154     /**
155      * @brief GetHashCode
156      *
157      * @since 1.0.0
158      * @return int, hascode of position
159      */
160     public override int GetHashCode()
161     {
162       return base.GetHashCode();
163     }
164
165     /**
166      * @brief Clone
167      *
168      * @since 1.0.0
169      * @return Position object
170      */
171     public Position Clone()
172     {
173       Position copy = new Position(X, Y, Z);
174       return copy;
175     }
176
177     // User-defined conversion from Position to Vector3
178     public static implicit operator Vector3(Position pos)
179     {
180       return new Vector3(pos.x, pos.y, pos.z);
181     }
182
183     public static implicit operator Position(Vector3 vec)
184     {
185       return new Position(vec.X, vec.Y, vec.Z);
186     }
187   }
188 }