2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using Tizen.NUI.Binding;
23 /// RelativeVector4 is a four-dimensional vector.
24 /// All values (x, y, and z) should be between [0, 1].
26 /// <since_tizen> 3 </since_tizen>
27 [TypeConverter(typeof(RelativeVector4TypeConverter))]
28 public class RelativeVector4 : Disposable
33 /// <since_tizen> 3 </since_tizen>
34 protected bool swigCMemOwn;
36 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
41 /// <since_tizen> 3 </since_tizen>
42 public RelativeVector4() : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
44 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50 /// <param name="x">The x component.</param>
51 /// <param name="y">The y component.</param>
52 /// <param name="z">The z component.</param>
53 /// <param name="w">The w component.</param>
54 /// <since_tizen> 3 </since_tizen>
55 public RelativeVector4(float x, float y, float z, float w) : this(Interop.Vector4.new_Vector4__SWIG_1(ValueCheck(x), ValueCheck(y), ValueCheck(z), ValueCheck(w)), true)
57 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
63 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
64 /// <since_tizen> 3 </since_tizen>
65 public RelativeVector4(RelativeVector2 relativeVector2) : this(Interop.Vector4.new_Vector4__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73 /// <param name="relativeVector3">The RelativeVector3 to create this vector from.</param>
74 /// <since_tizen> 3 </since_tizen>
75 public RelativeVector4(RelativeVector3 relativeVector3) : this(Interop.Vector4.new_Vector4__SWIG_4(RelativeVector3.getCPtr(relativeVector3)), true)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83 /// <since_tizen> 3 </since_tizen>
88 Interop.Vector4.Vector4_X_set(swigCPtr, ValueCheck(value));
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 float ret = Interop.Vector4.Vector4_X_get(swigCPtr);
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102 /// <since_tizen> 3 </since_tizen>
107 Interop.Vector4.Vector4_Y_set(swigCPtr, ValueCheck(value));
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 float ret = Interop.Vector4.Vector4_Y_get(swigCPtr);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 /// <since_tizen> 3 </since_tizen>
126 Interop.Vector4.Vector4_Z_set(swigCPtr, ValueCheck(value));
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 float ret = Interop.Vector4.Vector4_Z_get(swigCPtr);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 /// <since_tizen> 3 </since_tizen>
145 Interop.Vector4.Vector4_W_set(swigCPtr, ValueCheck(value));
146 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150 float ret = Interop.Vector4.Vector4_W_get(swigCPtr);
151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 /// The addition operator.
159 /// <param name="arg1">The vector to add.</param>
160 /// <param name="arg2">The vector to add.</param>
161 /// <returns>The vector containing the result of the addition.</returns>
162 /// <since_tizen> 3 </since_tizen>
163 public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
165 RelativeVector4 result = arg1.Add(arg2);
166 return ValueCheck(result);
170 /// The subtraction operator.
172 /// <param name="arg1">The vector to subtract.</param>
173 /// <param name="arg2">The vector to subtract.</param>
174 /// <returns>The vector containing the result of the subtraction.</returns>
175 /// <since_tizen> 3 </since_tizen>
176 public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
178 RelativeVector4 result = arg1.Subtract(arg2);
179 return ValueCheck(result);
183 /// The multiplication operator.
185 /// <param name="arg1">The vector to multiply.</param>
186 /// <param name="arg2">The vector to multiply.</param>
187 /// <returns>The vector containing the result of the multiplication.</returns>
188 /// <since_tizen> 3 </since_tizen>
189 public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
191 RelativeVector4 result = arg1.Multiply(arg2);
192 return ValueCheck(result);
196 /// The multiplication operator.
198 /// <param name="arg1">The vector to multiply.</param>
199 /// <param name="arg2">The float value to scale the vector.</param>
200 /// <returns>The vector containing the result of the scaling.</returns>
201 /// <since_tizen> 3 </since_tizen>
202 public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
204 RelativeVector4 result = arg1.Multiply(arg2);
205 return ValueCheck(result);
209 /// The division operator.
211 /// <param name="arg1">The vector to divide.</param>
212 /// <param name="arg2">The vector to divide.</param>
213 /// <returns>The vector containing the result of the division.</returns>
214 /// <since_tizen> 3 </since_tizen>
215 public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
217 RelativeVector4 result = arg1.Divide(arg2);
218 return ValueCheck(result);
222 /// The division operator.
224 /// <param name="arg1">The vector to divide.</param>
225 /// <param name="arg2">The float value to scale the vector by.</param>
226 /// <returns>The vector containing the result of the scaling.</returns>
227 /// <since_tizen> 3 </since_tizen>
228 public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
230 RelativeVector4 result = arg1.Divide(arg2);
231 return ValueCheck(result);
236 /// <since_tizen> 3 </since_tizen>
237 public static implicit operator Vector4(RelativeVector4 relativeVector4)
239 return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
244 /// <since_tizen> 3 </since_tizen>
245 public static implicit operator RelativeVector4(Vector4 vec)
247 return new RelativeVector4(ValueCheck(vec.X), ValueCheck(vec.Y), ValueCheck(vec.Z), ValueCheck(vec.W));
251 /// The const array subscript operator overload. Should be 0, 1 3 or 3.
253 /// <param name="index">The subscript index.</param>
254 /// <returns>The float at the given index.</returns>
255 /// <since_tizen> 3 </since_tizen>
256 public float this[uint index]
260 return ValueOfIndex(index);
265 /// Determines whether the specified object is equal to the current object.
267 /// <param name="obj">The object to compare with the current object.</param>
268 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
269 public override bool Equals(System.Object obj)
271 RelativeVector4 relativeVector4 = obj as RelativeVector4;
273 if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
281 /// Gets the the hash code of this RelativeVector4.
283 /// <returns>The Hash Code.</returns>
284 /// <since_tizen> 6 </since_tizen>
285 public override int GetHashCode()
287 return swigCPtr.Handle.GetHashCode();
291 /// Compares if the rhs is equal to.
293 /// <param name="rhs">The vector to compare.</param>
294 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
295 /// <since_tizen> 3 </since_tizen>
296 public bool EqualTo(RelativeVector4 rhs)
298 bool ret = Interop.Vector4.Vector4_EqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 /// Compares if the rhs is not equal to.
306 /// <param name="rhs">The vector to compare.</param>
307 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
308 /// <since_tizen> 3 </since_tizen>
309 public bool NotEqualTo(RelativeVector4 rhs)
311 bool ret = Interop.Vector4.Vector4_NotEqualTo(swigCPtr, RelativeVector4.getCPtr(rhs));
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
320 RelativeVector4 ret = new RelativeVector4(cPtr, false);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 internal static RelativeVector4 ValueCheck(RelativeVector4 relativeVector4)
327 if (relativeVector4.X < 0.0f)
329 relativeVector4.X = 0.0f;
330 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
332 else if (relativeVector4.X > 1.0f)
334 relativeVector4.X = 1.0f;
335 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
337 if (relativeVector4.Y < 0.0f)
339 relativeVector4.Y = 0.0f;
340 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
342 else if (relativeVector4.Y > 1.0f)
344 relativeVector4.Y = 1.0f;
345 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
347 if (relativeVector4.Z < 0.0f)
349 relativeVector4.Z = 0.0f;
350 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
352 else if (relativeVector4.Z > 1.0f)
354 relativeVector4.Z = 1.0f;
355 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
357 if (relativeVector4.W < 0.0f)
359 relativeVector4.W = 0.0f;
360 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
362 else if (relativeVector4.W > 1.0f)
364 relativeVector4.W = 1.0f;
365 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
367 return relativeVector4;
370 internal static float ValueCheck(float value)
375 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
377 else if (value > 1.0f)
380 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
385 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector4 obj)
387 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
390 internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn)
392 swigCMemOwn = cMemoryOwn;
393 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
399 /// <since_tizen> 3 </since_tizen>
400 protected override void Dispose(DisposeTypes type)
407 //Release your own unmanaged resources here.
408 //You should not access any managed member here except static instance.
409 //because the execution order of Finalizes is non-deterministic.
411 if (swigCPtr.Handle != global::System.IntPtr.Zero)
416 Interop.Vector4.delete_Vector4(swigCPtr);
418 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
423 private RelativeVector4 Add(RelativeVector4 rhs)
425 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Add(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 private RelativeVector4 Subtract(RelativeVector4 rhs)
432 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Subtract__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 private RelativeVector4 Multiply(RelativeVector4 rhs)
439 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Multiply__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
440 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 private RelativeVector4 Multiply(float rhs)
446 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 private RelativeVector4 Divide(RelativeVector4 rhs)
453 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Divide__SWIG_0(swigCPtr, RelativeVector4.getCPtr(rhs)), true);
454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 private RelativeVector4 Divide(float rhs)
460 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465 private float ValueOfIndex(uint index)
467 float ret = Interop.Vector4.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
468 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();