2 * Copyright (c) 2021 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 System.ComponentModel;
19 using Tizen.NUI.Binding;
24 /// RelativeVector4 is a four-dimensional vector.
25 /// All values (x, y, and z) should be between [0, 1].
27 /// <since_tizen> 3 </since_tizen>
28 [Binding.TypeConverter(typeof(RelativeVector4TypeConverter))]
29 public class RelativeVector4 : Disposable
35 /// <since_tizen> 3 </since_tizen>
36 public RelativeVector4() : this(Interop.Vector4.NewVector4(), true)
38 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44 /// <param name="x">The x component.</param>
45 /// <param name="y">The y component.</param>
46 /// <param name="z">The z component.</param>
47 /// <param name="w">The w component.</param>
48 /// <since_tizen> 3 </since_tizen>
49 public RelativeVector4(float x, float y, float z, float w) : this(Interop.Vector4.NewVector4(x, y, z, w), true)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
57 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
58 /// <since_tizen> 3 </since_tizen>
59 public RelativeVector4(RelativeVector2 relativeVector2) : this(Interop.Vector4.NewVector4WithVector2(RelativeVector2.getCPtr(relativeVector2)), true)
61 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
67 /// <param name="relativeVector3">The RelativeVector3 to create this vector from.</param>
68 /// <since_tizen> 3 </since_tizen>
69 public RelativeVector4(RelativeVector3 relativeVector3) : this(Interop.Vector4.NewVector4WithVector3(RelativeVector3.getCPtr(relativeVector3)), true)
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74 internal RelativeVector4(RelativeVector4ChangedCallback cb, float x, float y, float z, float w) : this(Interop.Vector4.NewVector4(x, y, z, w), true)
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79 internal delegate void RelativeVector4ChangedCallback(float x, float y, float z, float w);
80 private RelativeVector4ChangedCallback callback = null;
86 /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
89 /// // DO NOT use like the followings!
90 /// RelativeVector4 relativeVector4 = new RelativeVector4();
91 /// relativeVector4.X = 0.1f;
93 /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
94 /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
96 /// <since_tizen> 3 </since_tizen>
99 [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
102 Interop.Vector4.XSet(SwigCPtr, value);
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105 callback?.Invoke(X, Y, Z, W);
109 float ret = Interop.Vector4.XGet(SwigCPtr);
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
119 /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
122 /// // DO NOT use like the followings!
123 /// RelativeVector4 relativeVector4 = new RelativeVector4();
124 /// relativeVector4.Y = 0.5f;
126 /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
127 /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
129 /// <since_tizen> 3 </since_tizen>
132 [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
135 Interop.Vector4.YSet(SwigCPtr, value);
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138 callback?.Invoke(X, Y, Z, W);
142 float ret = Interop.Vector4.YGet(SwigCPtr);
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
152 /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
155 /// // DO NOT use like the followings!
156 /// RelativeVector4 relativeVector4 = new RelativeVector4();
157 /// relativeVector4.Z = 0.9f;
159 /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
160 /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
162 /// <since_tizen> 3 </since_tizen>
165 [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
168 Interop.Vector4.ZSet(SwigCPtr, value);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 callback?.Invoke(X, Y, Z, W);
175 float ret = Interop.Vector4.ZGet(SwigCPtr);
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
185 /// The setter is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor.
188 /// // DO NOT use like the followings!
189 /// RelativeVector4 relativeVector4 = new RelativeVector4();
190 /// relativeVector4.W = 1.0f;
192 /// float x = 0.1f, y = 0.5f, z = 0.9f, w = 1.0f;
193 /// RelativeVector4 relativeVector4 = new RelativeVector4(x, y, z, w);
195 /// <since_tizen> 3 </since_tizen>
198 [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new RelativeVector4(...) constructor")]
201 Interop.Vector4.WSet(SwigCPtr, value);
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 callback?.Invoke(X, Y, Z, W);
208 float ret = Interop.Vector4.WGet(SwigCPtr);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
215 /// The addition operator.
217 /// <param name="arg1">The vector to add.</param>
218 /// <param name="arg2">The vector to add.</param>
219 /// <returns>The vector containing the result of the addition.</returns>
220 /// <since_tizen> 3 </since_tizen>
221 public static RelativeVector4 operator +(RelativeVector4 arg1, RelativeVector4 arg2)
223 RelativeVector4 result = arg1?.Add(arg2);
228 /// The subtraction operator.
230 /// <param name="arg1">The vector to subtract.</param>
231 /// <param name="arg2">The vector to subtract.</param>
232 /// <returns>The vector containing the result of the subtraction.</returns>
233 /// <since_tizen> 3 </since_tizen>
234 public static RelativeVector4 operator -(RelativeVector4 arg1, RelativeVector4 arg2)
236 RelativeVector4 result = arg1?.Subtract(arg2);
241 /// The multiplication operator.
243 /// <param name="arg1">The vector to multiply.</param>
244 /// <param name="arg2">The vector to multiply.</param>
245 /// <returns>The vector containing the result of the multiplication.</returns>
246 /// <since_tizen> 3 </since_tizen>
247 public static RelativeVector4 operator *(RelativeVector4 arg1, RelativeVector4 arg2)
249 RelativeVector4 result = arg1?.Multiply(arg2);
254 /// The multiplication operator.
256 /// <param name="arg1">The vector to multiply.</param>
257 /// <param name="arg2">The float value to scale the vector.</param>
258 /// <returns>The vector containing the result of the scaling.</returns>
259 /// <since_tizen> 3 </since_tizen>
260 public static RelativeVector4 operator *(RelativeVector4 arg1, float arg2)
262 RelativeVector4 result = arg1?.Multiply(arg2);
267 /// The division operator.
269 /// <param name="arg1">The vector to divide.</param>
270 /// <param name="arg2">The vector to divide.</param>
271 /// <returns>The vector containing the result of the division.</returns>
272 /// <since_tizen> 3 </since_tizen>
273 public static RelativeVector4 operator /(RelativeVector4 arg1, RelativeVector4 arg2)
275 RelativeVector4 result = arg1?.Divide(arg2);
280 /// The division operator.
282 /// <param name="arg1">The vector to divide.</param>
283 /// <param name="arg2">The float value to scale the vector by.</param>
284 /// <returns>The vector containing the result of the scaling.</returns>
285 /// <since_tizen> 3 </since_tizen>
286 public static RelativeVector4 operator /(RelativeVector4 arg1, float arg2)
288 RelativeVector4 result = arg1?.Divide(arg2);
294 /// <since_tizen> 3 </since_tizen>
295 public static implicit operator Vector4(RelativeVector4 relativeVector4)
297 if (relativeVector4 == null)
301 return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
306 /// <since_tizen> 3 </since_tizen>
307 public static implicit operator RelativeVector4(Vector4 vec)
313 return new RelativeVector4(vec.X, vec.Y, vec.Z, vec.W);
317 /// The const array subscript operator overload. Should be 0, 1 3 or 3.
319 /// <param name="index">The subscript index.</param>
320 /// <returns>The float at the given index.</returns>
321 /// <since_tizen> 3 </since_tizen>
322 public float this[uint index]
326 return ValueOfIndex(index);
331 /// Determines whether the specified object is equal to the current object.
333 /// <param name="obj">The object to compare with the current object.</param>
334 /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
335 public override bool Equals(System.Object obj)
337 RelativeVector4 relativeVector4 = obj as RelativeVector4;
339 if (X == relativeVector4?.X && Y == relativeVector4?.Y && Z == relativeVector4?.Z && W == relativeVector4?.W)
347 /// Gets the hash code of this RelativeVector4.
349 /// <returns>The Hash Code.</returns>
350 /// <since_tizen> 6 </since_tizen>
351 public override int GetHashCode()
353 return SwigCPtr.Handle.GetHashCode();
357 /// Compares if the rhs is equal to.
359 /// <param name="rhs">The vector to compare.</param>
360 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
361 /// <since_tizen> 3 </since_tizen>
362 public bool EqualTo(RelativeVector4 rhs)
364 bool ret = Interop.Vector4.EqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
365 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
370 /// Compares if the rhs is not equal to.
372 /// <param name="rhs">The vector to compare.</param>
373 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
374 /// <since_tizen> 3 </since_tizen>
375 public bool NotEqualTo(RelativeVector4 rhs)
377 bool ret = Interop.Vector4.NotEqualTo(SwigCPtr, RelativeVector4.getCPtr(rhs));
378 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 internal static RelativeVector4 GetRelativeVector4FromPtr(global::System.IntPtr cPtr)
386 RelativeVector4 ret = new RelativeVector4(cPtr, false);
387 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
391 internal RelativeVector4(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
395 /// This will not be public opened.
396 [EditorBrowsable(EditorBrowsableState.Never)]
397 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
399 Interop.Vector4.DeleteVector4(swigCPtr);
402 private RelativeVector4 Add(RelativeVector4 rhs)
404 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Add(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409 private RelativeVector4 Subtract(RelativeVector4 rhs)
411 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Subtract(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
416 private RelativeVector4 Multiply(RelativeVector4 rhs)
418 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 private RelativeVector4 Multiply(float rhs)
425 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Multiply(SwigCPtr, rhs), true);
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 private RelativeVector4 Divide(RelativeVector4 rhs)
432 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, RelativeVector4.getCPtr(rhs)), true);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 private RelativeVector4 Divide(float rhs)
439 RelativeVector4 ret = new RelativeVector4(Interop.Vector4.Divide(SwigCPtr, rhs), true);
440 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 private float ValueOfIndex(uint index)
446 float ret = Interop.Vector4.ValueOfIndex(SwigCPtr, index);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();