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.
19 using Tizen.NUI.Binding;
24 /// RelativeVector3 is a three-dimensional vector.
25 /// All values (x, y, z and w) should be between [0, 1].
27 /// <since_tizen> 3 </since_tizen>
28 [TypeConverter(typeof(RelativeVector3TypeConverter))]
29 public class RelativeVector3 : Disposable
34 /// <since_tizen> 3 </since_tizen>
35 protected bool swigCMemOwn;
37 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
42 /// <since_tizen> 3 </since_tizen>
43 public RelativeVector3() : this(Interop.Vector3.new_Vector3__SWIG_0(), true)
45 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
51 /// <param name="x">The x component.</param>
52 /// <param name="y">The y component.</param>
53 /// <param name="z">The z component.</param>
54 /// <since_tizen> 3 </since_tizen>
55 public RelativeVector3(float x, float y, float z) : this(Interop.Vector3.new_Vector3__SWIG_1(ValueCheck(x), ValueCheck(y), ValueCheck(z)), 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 RelativeVector3(RelativeVector2 relativeVector2) : this(Interop.Vector3.new_Vector3__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73 /// <param name="relativeVector4">The RelativeVector4 to create this vector from.</param>
74 /// <since_tizen> 3 </since_tizen>
75 public RelativeVector3(RelativeVector4 relativeVector4) : this(Interop.Vector3.new_Vector3__SWIG_4(RelativeVector4.getCPtr(relativeVector4)), true)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83 /// <since_tizen> 3 </since_tizen>
88 Interop.Vector3.Vector3_X_set(swigCPtr, ValueCheck(value));
89 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 float ret = Interop.Vector3.Vector3_X_get(swigCPtr);
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102 /// <since_tizen> 3 </since_tizen>
107 Interop.Vector3.Vector3_Y_set(swigCPtr, ValueCheck(value));
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 float ret = Interop.Vector3.Vector3_Y_get(swigCPtr);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 /// <since_tizen> 3 </since_tizen>
126 Interop.Vector3.Vector3_Z_set(swigCPtr, ValueCheck(value));
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 float ret = Interop.Vector3.Vector3_Z_get(swigCPtr);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138 /// The addition operator.
140 /// <param name="arg1">The vector to add.</param>
141 /// <param name="arg2">Th vector to add.</param>
142 /// <returns>The vector containing the result of the addition.</returns>
143 /// <since_tizen> 3 </since_tizen>
144 public static RelativeVector3 operator +(RelativeVector3 arg1, RelativeVector3 arg2)
146 RelativeVector3 result = arg1.Add(arg2);
147 return ValueCheck(result);
151 /// The subtraction operator.
153 /// <param name="arg1">The vector to subtract.</param>
154 /// <param name="arg2">The vector to subtract.</param>
155 /// <returns>The vector containing the result of the subtraction.</returns>
156 /// <since_tizen> 3 </since_tizen>
157 public static RelativeVector3 operator -(RelativeVector3 arg1, RelativeVector3 arg2)
159 RelativeVector3 result = arg1.Subtract(arg2);
160 return ValueCheck(result);
164 /// The multiplication operator.
166 /// <param name="arg1">The vector to multiply.</param>
167 /// <param name="arg2">The vector to multiply.</param>
168 /// <returns>The vector containing the result of the multiplication.</returns>
169 /// <since_tizen> 3 </since_tizen>
170 public static RelativeVector3 operator *(RelativeVector3 arg1, RelativeVector3 arg2)
172 RelativeVector3 result = arg1.Multiply(arg2);
173 return ValueCheck(result);
177 /// The multiplication operator.
179 /// <param name="arg1">The vector to multiply.</param>
180 /// <param name="arg2">The float value to scale the vector.</param>
181 /// <returns>The vector containing the result of the scaling.</returns>
182 /// <since_tizen> 3 </since_tizen>
183 public static RelativeVector3 operator *(RelativeVector3 arg1, float arg2)
185 RelativeVector3 result = arg1.Multiply(arg2);
186 return ValueCheck(result);
190 /// The division operator.
192 /// <param name="arg1">The vector to divide.</param>
193 /// <param name="arg2">The vector to divide.</param>
194 /// <returns>The vector containing the result of the division.</returns>
195 /// <since_tizen> 3 </since_tizen>
196 public static RelativeVector3 operator /(RelativeVector3 arg1, RelativeVector3 arg2)
198 RelativeVector3 result = arg1.Divide(arg2);
199 return ValueCheck(result);
203 /// The division operator.
205 /// <param name="arg1">The vector to divide.</param>
206 /// <param name="arg2">The float value to scale the vector by.</param>
207 /// <returns>The vector containing the result of the scaling.</returns>
208 /// <since_tizen> 3 </since_tizen>
209 public static RelativeVector3 operator /(RelativeVector3 arg1, float arg2)
211 RelativeVector3 result = arg1.Divide(arg2);
212 return ValueCheck(result);
217 /// <since_tizen> 3 </since_tizen>
218 public static implicit operator Vector3(RelativeVector3 relativeVector3)
220 return new Vector3(relativeVector3.X, relativeVector3.Y, relativeVector3.Z);
225 /// <since_tizen> 3 </since_tizen>
226 public static implicit operator RelativeVector3(Vector3 vec)
228 return new RelativeVector3(ValueCheck(vec.X), ValueCheck(vec.Y), ValueCheck(vec.Z));
232 /// The const array subscript operator overload. Should be 0, 1 or 2.
234 /// <param name="index">The subscript index.</param>
235 /// <returns>The float at the given index.</returns>
236 /// <since_tizen> 3 </since_tizen>
237 public float this[uint index]
241 return ValueOfIndex(index);
246 /// Determines whether the specified object is equal to the current object.
248 /// <param name="obj">The object to compare with the current object.</param>
249 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
250 public override bool Equals(System.Object obj)
252 RelativeVector3 relativeVector3 = obj as RelativeVector3;
254 if (X == relativeVector3?.X && Y == relativeVector3?.Y && Z == relativeVector3?.Z)
262 /// Gets the the hash code of this RelativeVector3.
264 /// <returns>The Hash Code.</returns>
265 /// <since_tizen> 6 </since_tizen>
266 public override int GetHashCode()
268 return swigCPtr.Handle.GetHashCode();
272 /// Compares if the rhs is equal to.
274 /// <param name="rhs">The vector to compare.</param>
275 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
276 /// <since_tizen> 3 </since_tizen>
277 public bool EqualTo(RelativeVector3 rhs)
279 bool ret = Interop.Vector3.Vector3_EqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Compares if the rhs is not equal to.
287 /// <param name="rhs">The vector to compare.</param>
288 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
289 /// <since_tizen> 3 </since_tizen>
290 public bool NotEqualTo(RelativeVector3 rhs)
292 bool ret = Interop.Vector3.Vector3_NotEqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 internal static RelativeVector3 ValueCheck(RelativeVector3 relativeVector3)
299 if (relativeVector3.X < 0.0f)
301 relativeVector3.X = 0.0f;
302 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
304 else if (relativeVector3.X > 1.0f)
306 relativeVector3.X = 1.0f;
307 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
309 if (relativeVector3.Y < 0.0f)
311 relativeVector3.Y = 0.0f;
312 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
314 else if (relativeVector3.Y > 1.0f)
316 relativeVector3.Y = 1.0f;
317 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
319 if (relativeVector3.Z < 0.0f)
321 relativeVector3.Z = 0.0f;
322 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
324 else if (relativeVector3.Z > 1.0f)
326 relativeVector3.Z = 1.0f;
327 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
329 return relativeVector3;
332 internal static float ValueCheck(float value)
337 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
339 else if (value > 1.0f)
342 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
349 internal static RelativeVector3 GetRelativeVector3FromPtr(global::System.IntPtr cPtr)
351 RelativeVector3 ret = new RelativeVector3(cPtr, false);
352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector3 obj)
358 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
361 internal RelativeVector3(global::System.IntPtr cPtr, bool cMemoryOwn)
363 swigCMemOwn = cMemoryOwn;
364 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
370 /// <since_tizen> 3 </since_tizen>
371 protected override void Dispose(DisposeTypes type)
378 //Release your own unmanaged resources here.
379 //You should not access any managed member here except static instance.
380 //because the execution order of Finalizes is non-deterministic.
382 if (swigCPtr.Handle != global::System.IntPtr.Zero)
387 Interop.Vector3.delete_Vector3(swigCPtr);
389 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
394 private RelativeVector3 Add(RelativeVector3 rhs)
396 RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Vector3_Add(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401 private RelativeVector3 Subtract(RelativeVector3 rhs)
403 RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Vector3_Subtract__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 private RelativeVector3 Multiply(RelativeVector3 rhs)
410 RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Vector3_Multiply__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 private RelativeVector3 Multiply(float rhs)
417 RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 private RelativeVector3 Divide(RelativeVector3 rhs)
424 RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Vector3_Divide__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429 private RelativeVector3 Divide(float rhs)
431 RelativeVector3 ret = new RelativeVector3(Interop.Vector3.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 private float ValueOfIndex(uint index)
438 float ret = Interop.Vector3.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();