1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 /// A four dimensional vector.
23 public class Vector4 : global::System.IDisposable
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 protected bool swigCMemOwn;
28 internal Vector4(global::System.IntPtr cPtr, bool cMemoryOwn)
30 swigCMemOwn = cMemoryOwn;
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Vector4 obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 //A Flag to check who called Dispose(). (By User or DisposeQueue)
40 private bool isDisposeQueued = false;
41 //A Flat to check if it is already disposed.
42 protected bool disposed = false;
48 isDisposeQueued = true;
49 DisposeQueue.Instance.Add(this);
55 //Throw excpetion if Dispose() is called in separate thread.
56 if (!Window.IsInstalled())
58 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
63 Dispose(DisposeTypes.Implicit);
67 Dispose(DisposeTypes.Explicit);
68 System.GC.SuppressFinalize(this);
72 protected virtual void Dispose(DisposeTypes type)
79 if(type == DisposeTypes.Explicit)
82 //Release your own managed resources here.
83 //You should release all of your own disposable objects here.
86 //Release your own unmanaged resources here.
87 //You should not access any managed member here except static instance.
88 //because the execution order of Finalizes is non-deterministic.
90 if (swigCPtr.Handle != global::System.IntPtr.Zero)
95 NDalicPINVOKE.delete_Vector4(swigCPtr);
97 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
103 /// Addition operator.
105 /// <param name="arg1">First value</param>
106 /// <param name="arg2">Second value</param>
107 /// <returns>A vector containing the result of the addition</returns>
108 public static Vector4 operator +(Vector4 arg1, Vector4 arg2)
110 return arg1.Add(arg2);
114 /// Subtraction operator.
116 /// <param name="arg1">First value</param>
117 /// <param name="arg2">Second value</param>
118 /// <returns>A vector containing the result of the subtraction</returns>
119 public static Vector4 operator -(Vector4 arg1, Vector4 arg2)
121 return arg1.Subtract(arg2);
125 /// Unary negation operator.
127 /// <param name="arg1">Target Value</param>
128 /// <returns>A vector containg the negation</returns>
129 public static Vector4 operator -(Vector4 arg1)
131 return arg1.Subtract();
135 /// Multiplication operator.
137 /// <param name="arg1">First Value</param>
138 /// <param name="arg2">Second Value</param>
139 /// <returns>A vector containing the result of the multiplication</returns>
140 public static Vector4 operator *(Vector4 arg1, Vector4 arg2)
142 return arg1.Multiply(arg2);
146 /// Multiplication operator.
148 /// <param name="arg1">First Value</param>
149 /// <param name="arg2">The float value to scale the vector</param>
150 /// <returns>A vector containing the result of the scaling</returns>
151 public static Vector4 operator *(Vector4 arg1, float arg2)
153 return arg1.Multiply(arg2);
157 /// Division operator.
159 /// <param name="arg1">First Value</param>
160 /// <param name="arg2">Second Value</param>
161 /// <returns>A vector containing the result of the division</returns>
162 public static Vector4 operator /(Vector4 arg1, Vector4 arg2)
164 return arg1.Divide(arg2);
168 /// Division operator.
170 /// <param name="arg1">First Value</param>
171 /// <param name="arg2">The float value to scale the vector by</param>
172 /// <returns>A vector containing the result of the scaling</returns>
173 public static Vector4 operator /(Vector4 arg1, float arg2)
175 return arg1.Divide(arg2);
179 /// Array subscript operator overload.
181 /// <param name="index">Subscript index</param>
182 /// <returns>The float at the given index</returns>
183 public float this[uint index]
187 return ValueOfIndex(index);
191 internal static Vector4 GetVector4FromPtr(global::System.IntPtr cPtr)
193 Vector4 ret = new Vector4(cPtr, false);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 /// Default constructor, initializes the vector to 0.
201 public Vector4() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 /// Conversion constructor from four floats.
209 /// <param name="x">x (or r/s) component</param>
210 /// <param name="y">y (or g/t) component</param>
211 /// <param name="z">z (or b/p) component</param>
212 /// <param name="w">w (or a/q) component</param>
213 public Vector4(float x, float y, float z, float w) : this(NDalicPINVOKE.new_Vector4__SWIG_1(x, y, z, w), true)
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// Conversion constructor from an array of four floats.
221 /// <param name="array">array Array of either xyzw/rgba/stpq</param>
222 public Vector4(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228 /// Conversion constructor from Vector2.
230 /// <param name="vec2">Vector2 to copy from, z and w are initialized to 0</param>
231 public Vector4(Vector2 vec2) : this(NDalicPINVOKE.new_Vector4__SWIG_3(Vector2.getCPtr(vec2)), true)
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 /// Conversion constructor from Vector3.
239 /// <param name="vec3">Vector3 to copy from, w is initialized to 0</param>
240 public Vector4(Vector3 vec3) : this(NDalicPINVOKE.new_Vector4__SWIG_4(Vector3.getCPtr(vec3)), true)
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 /// (1.0f,1.0f,1.0f,1.0f)
248 public static Vector4 One
252 global::System.IntPtr cPtr = NDalicPINVOKE.Vector4_ONE_get();
253 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260 /// (1.0f,0.0f,0.0f,0.0f)
262 public static Vector4 XAxis
266 global::System.IntPtr cPtr = NDalicPINVOKE.Vector4_XAXIS_get();
267 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 /// (0.0f,1.0f,0.0f,0.0f)
276 public static Vector4 YAxis
280 global::System.IntPtr cPtr = NDalicPINVOKE.Vector4_YAXIS_get();
281 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 /// (0.0f,0.0f,1.0f,0.0f)
290 public static Vector4 ZAxis
294 global::System.IntPtr cPtr = NDalicPINVOKE.Vector4_ZAXIS_get();
295 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 /// (0.0f, 0.0f, 0.0f, 0.0f)
304 public static Vector4 Zero
308 global::System.IntPtr cPtr = NDalicPINVOKE.Vector4_ZERO_get();
309 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
310 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315 private Vector4 Add(Vector4 rhs)
317 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Add(swigCPtr, Vector4.getCPtr(rhs)), true);
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322 private Vector4 AddAssign(Vector4 rhs)
324 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Vector4.getCPtr(rhs)), false);
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 private Vector4 Subtract(Vector4 rhs)
331 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), true);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 private Vector4 SubtractAssign(Vector4 rhs)
338 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Vector4.getCPtr(rhs)), false);
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
343 private Vector4 Multiply(Vector4 rhs)
345 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), true);
346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 private Vector4 Multiply(float rhs)
352 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 private Vector4 MultiplyAssign(Vector4 rhs)
359 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), false);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 private Vector4 MultiplyAssign(float rhs)
366 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371 private Vector4 Divide(Vector4 rhs)
373 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), true);
374 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 private Vector4 Divide(float rhs)
380 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 private Vector4 DivideAssign(Vector4 rhs)
387 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), false);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 private Vector4 DivideAssign(float rhs)
394 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 private Vector4 Subtract()
401 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 private bool EqualTo(Vector4 rhs)
408 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Vector4.getCPtr(rhs));
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 private bool NotEqualTo(Vector4 rhs)
415 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Vector4.getCPtr(rhs));
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420 private float ValueOfIndex(uint index)
422 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 internal float Dot(Vector3 other)
429 float ret = NDalicPINVOKE.Vector4_Dot__SWIG_0(swigCPtr, Vector3.getCPtr(other));
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 internal float Dot(Vector4 other)
436 float ret = NDalicPINVOKE.Vector4_Dot__SWIG_1(swigCPtr, Vector4.getCPtr(other));
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441 internal float Dot4(Vector4 other)
443 float ret = NDalicPINVOKE.Vector4_Dot4(swigCPtr, Vector4.getCPtr(other));
444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 internal Vector4 Cross(Vector4 other)
450 Vector4 ret = new Vector4(NDalicPINVOKE.Vector4_Cross(swigCPtr, Vector4.getCPtr(other)), true);
451 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 /// Returns the length of the vector.
458 /// <returns>The length</returns>
459 public float Length()
461 float ret = NDalicPINVOKE.Vector4_Length(swigCPtr);
462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 /// Returns the length of the vector squared.<br>
468 /// This is faster than using Length() when performing
469 /// threshold checks as it avoids use of the square root.<br>
471 /// <returns>The length of the vector squared</returns>
472 public float LengthSquared()
474 float ret = NDalicPINVOKE.Vector4_LengthSquared(swigCPtr);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 /// Normalizes the vector.<br>
481 /// Sets the vector to unit length whilst maintaining its direction.<br>
483 public void Normalize()
485 NDalicPINVOKE.Vector4_Normalize(swigCPtr);
486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490 /// Clamps the vector between minimum and maximum vectors.
492 /// <param name="min">The minimum vector</param>
493 /// <param name="max">The maximum vector</param>
494 public void Clamp(Vector4 min, Vector4 max)
496 NDalicPINVOKE.Vector4_Clamp(swigCPtr, Vector4.getCPtr(min), Vector4.getCPtr(max));
497 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
500 internal SWIGTYPE_p_float AsFloat()
502 global::System.IntPtr cPtr = NDalicPINVOKE.Vector4_AsFloat__SWIG_0(swigCPtr);
503 SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr, false);
504 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
515 NDalicPINVOKE.Vector4_X_set(swigCPtr, value);
516 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 float ret = NDalicPINVOKE.Vector4_X_get(swigCPtr);
521 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
534 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
539 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
551 NDalicPINVOKE.Vector4_s_set(swigCPtr, value);
552 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556 float ret = NDalicPINVOKE.Vector4_s_get(swigCPtr);
557 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569 NDalicPINVOKE.Vector4_Y_set(swigCPtr, value);
570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 float ret = NDalicPINVOKE.Vector4_Y_get(swigCPtr);
575 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
588 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
593 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605 NDalicPINVOKE.Vector4_t_set(swigCPtr, value);
606 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 float ret = NDalicPINVOKE.Vector4_t_get(swigCPtr);
611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623 NDalicPINVOKE.Vector4_Z_set(swigCPtr, value);
624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 float ret = NDalicPINVOKE.Vector4_Z_get(swigCPtr);
629 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
642 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
647 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
659 NDalicPINVOKE.Vector4_p_set(swigCPtr, value);
660 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 float ret = NDalicPINVOKE.Vector4_p_get(swigCPtr);
665 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 NDalicPINVOKE.Vector4_W_set(swigCPtr, value);
678 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
682 float ret = NDalicPINVOKE.Vector4_W_get(swigCPtr);
683 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
695 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
701 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
713 NDalicPINVOKE.Vector4_q_set(swigCPtr, value);
714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718 float ret = NDalicPINVOKE.Vector4_q_get(swigCPtr);
719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();