Merge "Implement normalized Vector2/3/4 class." into tizen
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Vector2.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 3.0.9
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10
11 namespace Tizen.NUI
12 {
13
14     /// <summary>
15     /// A two dimensional vector.
16     /// </summary>
17     public class Vector2 : global::System.IDisposable
18     {
19         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
20         protected bool swigCMemOwn;
21
22         internal Vector2(global::System.IntPtr cPtr, bool cMemoryOwn)
23         {
24             swigCMemOwn = cMemoryOwn;
25             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
26         }
27
28         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Vector2 obj)
29         {
30             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
31         }
32
33         ~Vector2()
34         {
35             DisposeQueue.Instance.Add(this);
36         }
37
38         public virtual void Dispose()
39         {
40             if (!Stage.IsInstalled())
41             {
42                 DisposeQueue.Instance.Add(this);
43                 return;
44             }
45
46             lock (this)
47             {
48                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
49                 {
50                     if (swigCMemOwn)
51                     {
52                         swigCMemOwn = false;
53                         NDalicPINVOKE.delete_Vector2(swigCPtr);
54                     }
55                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
56                 }
57                 global::System.GC.SuppressFinalize(this);
58             }
59         }
60
61         /// <summary>
62         /// Addition operator.
63         /// </summary>
64         /// <param name="arg1">First value</param>
65         /// <param name="arg2">Second value</param>
66         /// <returns>A vector containing the result of the addition</returns>
67         public static Vector2 operator +(Vector2 arg1, Vector2 arg2)
68         {
69             return arg1.Add(arg2);
70         }
71
72         /// <summary>
73         /// Subtraction operator.
74         /// </summary>
75         /// <param name="arg1">First value</param>
76         /// <param name="arg2">Second value</param>
77         /// <returns>A vector containing the result of the subtraction</returns>
78         public static Vector2 operator -(Vector2 arg1, Vector2 arg2)
79         {
80             return arg1.Subtract(arg2);
81         }
82
83         /// <summary>
84         /// Unary negation operator.
85         /// </summary>
86         /// <param name="arg1">Target Value</param>
87         /// <returns>A vector containg the negation</returns>
88         public static Vector2 operator -(Vector2 arg1)
89         {
90             return arg1.Subtract();
91         }
92
93         /// <summary>
94         /// Multiplication operator.
95         /// </summary>
96         /// <param name="arg1">First Value</param>
97         /// <param name="arg2">Second Value</param>
98         /// <returns>A vector containing the result of the multiplication</returns>
99         public static Vector2 operator *(Vector2 arg1, Vector2 arg2)
100         {
101             return arg1.Multiply(arg2);
102         }
103
104         /// <summary>
105         /// Multiplication operator.
106         /// </summary>
107         /// <param name="arg1">First Value</param>
108         /// <param name="arg2">The float value to scale the vector</param>
109         /// <returns>A vector containing the result of the scaling</returns>
110         public static Vector2 operator *(Vector2 arg1, float arg2)
111         {
112             return arg1.Multiply(arg2);
113         }
114
115         /// <summary>
116         /// Division operator.
117         /// </summary>
118         /// <param name="arg1">First Value</param>
119         /// <param name="arg2">Second Value</param>
120         /// <returns>A vector containing the result of the division</returns>
121         public static Vector2 operator /(Vector2 arg1, Vector2 arg2)
122         {
123             return arg1.Divide(arg2);
124         }
125
126         /// <summary>
127         /// Division operator.
128         /// </summary>
129         /// <param name="arg1">First Value</param>
130         /// <param name="arg2">The float value to scale the vector by</param>
131         /// <returns>A vector containing the result of the scaling</returns>
132         public static Vector2 operator /(Vector2 arg1, float arg2)
133         {
134             return arg1.Divide(arg2);
135         }
136
137         /// <summary>
138         /// Array subscript operator overload.
139         /// </summary>
140         /// <param name="index">Subscript index</param>
141         /// <returns>The float at the given index</returns>
142         public float this[uint index]
143         {
144             get
145             {
146                 return ValueOfIndex(index);
147             }
148         }
149
150         internal static Vector2 GetVector2FromPtr(global::System.IntPtr cPtr)
151         {
152             Vector2 ret = new Vector2(cPtr, false);
153             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154             return ret;
155         }
156
157         /// <summary>
158         /// Default constructor, initializes the vector to 0.
159         /// </summary>
160         public Vector2() : this(NDalicPINVOKE.new_Vector2__SWIG_0(), true)
161         {
162             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163         }
164
165         /// <summary>
166         /// Constructor.
167         /// </summary>
168         /// <param name="x">x or width component</param>
169         /// <param name="y">y or height component</param>
170         public Vector2(float x, float y) : this(NDalicPINVOKE.new_Vector2__SWIG_1(x, y), true)
171         {
172             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173         }
174
175         /// <summary>
176         /// Conversion constructor from an array of two floats.
177         /// </summary>
178         /// <param name="array">Array of xy</param>
179         public Vector2(float[] array) : this(NDalicPINVOKE.new_Vector2__SWIG_2(array), true)
180         {
181             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182         }
183
184         /// <summary>
185         /// Constructor.
186         /// </summary>
187         /// <param name="vec3">Vector3 to create this vector from</param>
188         public Vector2(Vector3 vec3) : this(NDalicPINVOKE.new_Vector2__SWIG_3(Vector3.getCPtr(vec3)), true)
189         {
190             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191         }
192
193         /// <summary>
194         /// Constructor.
195         /// </summary>
196         /// <param name="vec4">Vector4 to create this vector from</param>
197         public Vector2(Vector4 vec4) : this(NDalicPINVOKE.new_Vector2__SWIG_4(Vector4.getCPtr(vec4)), true)
198         {
199             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200         }
201
202         /// <summary>
203         /// (1.0f,1.0f)
204         /// </summary>
205         public static Vector2 One
206         {
207             get
208             {
209                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_ONE_get();
210                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
211                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212                 return ret;
213             }
214         }
215
216         /// <summary>
217         /// Vector representing the X axis
218         /// </summary>
219         public static Vector2 XAxis
220         {
221             get
222             {
223                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_XAXIS_get();
224                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
225                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226                 return ret;
227             }
228         }
229
230         /// <summary>
231         /// Vector representing the Y axis
232         /// </summary>
233         public static Vector2 YAxis
234         {
235             get
236             {
237                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_YAXIS_get();
238                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
239                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240                 return ret;
241             }
242         }
243
244         /// <summary>
245         /// Vector representing the negative X axis
246         /// </summary>
247         public static Vector2 NegativeXAxis
248         {
249             get
250             {
251                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_NEGATIVE_XAXIS_get();
252                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
253                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254                 return ret;
255             }
256         }
257
258         /// <summary>
259         /// Vector representing the negative Y axis
260         /// </summary>
261         public static Vector2 NegativeYAxis
262         {
263             get
264             {
265                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_NEGATIVE_YAXIS_get();
266                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
267                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268                 return ret;
269             }
270         }
271
272         /// <summary>
273         /// (0.0f, 0.0f)
274         /// </summary>
275         public static Vector2 Zero
276         {
277             get
278             {
279                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_ZERO_get();
280                 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
281                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282                 return ret;
283             }
284         }
285
286         internal Vector2 Assign(float[] array)
287         {
288             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Assign__SWIG_0(swigCPtr, array), false);
289             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290             return ret;
291         }
292
293         internal Vector2 Assign(Vector3 rhs)
294         {
295             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Assign__SWIG_1(swigCPtr, Vector3.getCPtr(rhs)), false);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             return ret;
298         }
299
300         internal Vector2 Assign(Vector4 rhs)
301         {
302             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Assign__SWIG_2(swigCPtr, Vector4.getCPtr(rhs)), false);
303             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304             return ret;
305         }
306
307         internal Vector2 Add(Vector2 rhs)
308         {
309             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Add(swigCPtr, Vector2.getCPtr(rhs)), true);
310             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311             return ret;
312         }
313
314         internal Vector2 AddAssign(Vector2 rhs)
315         {
316             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_AddAssign(swigCPtr, Vector2.getCPtr(rhs)), false);
317             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318             return ret;
319         }
320
321         internal Vector2 Subtract(Vector2 rhs)
322         {
323             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Subtract__SWIG_0(swigCPtr, Vector2.getCPtr(rhs)), true);
324             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325             return ret;
326         }
327
328         internal Vector2 SubtractAssign(Vector2 rhs)
329         {
330             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_SubtractAssign(swigCPtr, Vector2.getCPtr(rhs)), false);
331             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332             return ret;
333         }
334
335         internal Vector2 Multiply(Vector2 rhs)
336         {
337             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Multiply__SWIG_0(swigCPtr, Vector2.getCPtr(rhs)), true);
338             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339             return ret;
340         }
341
342         internal Vector2 Multiply(float rhs)
343         {
344             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Multiply__SWIG_1(swigCPtr, rhs), true);
345             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346             return ret;
347         }
348
349         internal Vector2 MultiplyAssign(Vector2 rhs)
350         {
351             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_MultiplyAssign__SWIG_0(swigCPtr, Vector2.getCPtr(rhs)), false);
352             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353             return ret;
354         }
355
356         internal Vector2 MultiplyAssign(float rhs)
357         {
358             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
359             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360             return ret;
361         }
362
363         internal Vector2 Divide(Vector2 rhs)
364         {
365             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Divide__SWIG_0(swigCPtr, Vector2.getCPtr(rhs)), true);
366             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
367             return ret;
368         }
369
370         internal Vector2 Divide(float rhs)
371         {
372             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Divide__SWIG_1(swigCPtr, rhs), true);
373             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374             return ret;
375         }
376
377         internal Vector2 DivideAssign(Vector2 rhs)
378         {
379             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_DivideAssign__SWIG_0(swigCPtr, Vector2.getCPtr(rhs)), false);
380             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381             return ret;
382         }
383
384         internal Vector2 DivideAssign(float rhs)
385         {
386             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_DivideAssign__SWIG_1(swigCPtr, rhs), false);
387             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388             return ret;
389         }
390
391         internal Vector2 Subtract()
392         {
393             Vector2 ret = new Vector2(NDalicPINVOKE.Vector2_Subtract__SWIG_1(swigCPtr), true);
394             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395             return ret;
396         }
397
398         internal bool EqualTo(Vector2 rhs)
399         {
400             bool ret = NDalicPINVOKE.Vector2_EqualTo(swigCPtr, Vector2.getCPtr(rhs));
401             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402             return ret;
403         }
404
405         internal bool NotEqualTo(Vector2 rhs)
406         {
407             bool ret = NDalicPINVOKE.Vector2_NotEqualTo(swigCPtr, Vector2.getCPtr(rhs));
408             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409             return ret;
410         }
411
412         internal float ValueOfIndex(uint index)
413         {
414             float ret = NDalicPINVOKE.Vector2_ValueOfIndex__SWIG_0(swigCPtr, index);
415             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
416             return ret;
417         }
418
419         /// <summary>
420         /// Returns the length of the vector.
421         /// </summary>
422         /// <returns>The length of the vector</returns>
423         public float Length()
424         {
425             float ret = NDalicPINVOKE.Vector2_Length(swigCPtr);
426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427             return ret;
428         }
429
430         /// <summary>
431         /// Returns the length of the vector squared.<br>
432         /// This is more efficient than Length() for threshold
433         /// testing as it avoids the use of a square root.<br>
434         /// </summary>
435         /// <returns>The length of the vector squared</returns>
436         public float LengthSquared()
437         {
438             float ret = NDalicPINVOKE.Vector2_LengthSquared(swigCPtr);
439             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
440             return ret;
441         }
442
443         /// <summary>
444         /// Sets the vector to be unit length, whilst maintaining its direction.
445         /// </summary>
446         public void Normalize()
447         {
448             NDalicPINVOKE.Vector2_Normalize(swigCPtr);
449             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450         }
451
452         /// <summary>
453         /// Clamps the vector between minimum and maximum vectors.
454         /// </summary>
455         /// <param name="min">The minimum vector</param>
456         /// <param name="max">The maximum vector</param>
457         public void Clamp(Vector2 min, Vector2 max)
458         {
459             NDalicPINVOKE.Vector2_Clamp(swigCPtr, Vector2.getCPtr(min), Vector2.getCPtr(max));
460             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
461         }
462
463         internal SWIGTYPE_p_float AsFloat()
464         {
465             global::System.IntPtr cPtr = NDalicPINVOKE.Vector2_AsFloat__SWIG_0(swigCPtr);
466             SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr, false);
467             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468             return ret;
469         }
470
471         /// <summary>
472         /// x component
473         /// </summary>
474         public float X
475         {
476             set
477             {
478                 NDalicPINVOKE.Vector2_X_set(swigCPtr, value);
479                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480             }
481             get
482             {
483                 float ret = NDalicPINVOKE.Vector2_X_get(swigCPtr);
484                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485                 return ret;
486             }
487         }
488
489         /// <summary>
490         /// width
491         /// </summary>
492         public float Width
493         {
494             set
495             {
496                 NDalicPINVOKE.Vector2_Width_set(swigCPtr, value);
497                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498             }
499             get
500             {
501                 float ret = NDalicPINVOKE.Vector2_Width_get(swigCPtr);
502                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
503                 return ret;
504             }
505         }
506
507         /// <summary>
508         /// y component
509         /// </summary>
510         public float Y
511         {
512             set
513             {
514                 NDalicPINVOKE.Vector2_Y_set(swigCPtr, value);
515                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
516             }
517             get
518             {
519                 float ret = NDalicPINVOKE.Vector2_Y_get(swigCPtr);
520                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521                 return ret;
522             }
523         }
524
525         /// <summary>
526         /// height
527         /// </summary>
528         public float Height
529         {
530             set
531             {
532                 NDalicPINVOKE.Vector2_Height_set(swigCPtr, value);
533                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
534             }
535             get
536             {
537                 float ret = NDalicPINVOKE.Vector2_Height_get(swigCPtr);
538                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539                 return ret;
540             }
541         }
542
543     }
544
545 }