/*
* Copyright(c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using Tizen.NUI.Binding;
namespace Tizen.NUI
{
///
/// A four-dimensional vector.
///
/// 3
[TypeConverter(typeof(Vector4TypeConverter))]
public class Vector4 : Disposable
{
///
/// swigCMemOwn.
///
/// 3
protected bool swigCMemOwn;
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
///
/// The default constructor initializes the vector to 0.
///
/// 3
public Vector4() : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The conversion constructor from four floats.
///
/// The x (or r/s) component.
/// The y (or g/t) component.
/// The z (or b/p) component.
/// The w (or a/q) component.
/// 3
public Vector4(float x, float y, float z, float w) : this(Interop.Vector4.new_Vector4__SWIG_1(x, y, z, w), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The conversion constructor from an array of four floats.
///
/// The array of either xyzw/rgba/stpq.
/// 3
public Vector4(float[] array) : this(Interop.Vector4.new_Vector4__SWIG_2(array), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The conversion constructor from Vector2.
///
/// Vector2 to copy from, z and w are initialized to 0.
/// 3
public Vector4(Vector2 vec2) : this(Interop.Vector4.new_Vector4__SWIG_3(Vector2.getCPtr(vec2)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// The conversion constructor from Vector3.
///
/// Vector3 to copy from, w is initialized to 0.
/// 3
public Vector4(Vector3 vec3) : this(Interop.Vector4.new_Vector4__SWIG_4(Vector3.getCPtr(vec3)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal Vector4(global::System.IntPtr cPtr, bool cMemoryOwn)
{
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
///
/// (1.0f,1.0f,1.0f,1.0f).
///
/// 3
public static Vector4 One
{
get
{
global::System.IntPtr cPtr = Interop.Vector4.Vector4_ONE_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// (1.0f,0.0f,0.0f,0.0f).
///
/// 3
public static Vector4 XAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector4.Vector4_XAXIS_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// (0.0f,1.0f,0.0f,0.0f).
///
/// 3
public static Vector4 YAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector4.Vector4_YAXIS_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// (0.0f,0.0f,1.0f,0.0f).
///
/// 3
public static Vector4 ZAxis
{
get
{
global::System.IntPtr cPtr = Interop.Vector4.Vector4_ZAXIS_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// (0.0f, 0.0f, 0.0f, 0.0f).
///
/// 3
public static Vector4 Zero
{
get
{
global::System.IntPtr cPtr = Interop.Vector4.Vector4_ZERO_get();
Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The x component.
///
/// 3
public float X
{
set
{
Interop.Vector4.Vector4_X_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_X_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The red component.
///
/// 3
public float R
{
set
{
Interop.Vector4.Vector4_r_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_r_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The s component.
///
/// 3
public float S
{
set
{
Interop.Vector4.Vector4_s_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_s_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The y component.
///
/// 3
public float Y
{
set
{
Interop.Vector4.Vector4_Y_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_Y_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The green component.
///
/// 3
public float G
{
set
{
Interop.Vector4.Vector4_g_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_g_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The t component.
///
/// 3
public float T
{
set
{
Interop.Vector4.Vector4_t_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_t_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The z component.
///
/// 3
public float Z
{
set
{
Interop.Vector4.Vector4_Z_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_Z_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The blue component.
///
/// 3
public float B
{
set
{
Interop.Vector4.Vector4_b_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_b_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The p component.
///
/// 3
public float P
{
set
{
Interop.Vector4.Vector4_p_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_p_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The w component.
///
/// 3
public float W
{
set
{
Interop.Vector4.Vector4_W_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_W_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The alpha component.
///
/// 3
public float A
{
set
{
Interop.Vector4.Vector4_a_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_a_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The q component.
///
/// 3
public float Q
{
set
{
Interop.Vector4.Vector4_q_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = Interop.Vector4.Vector4_q_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// The array subscript operator overload.
///
/// The subscript index.
/// The float at the given index.
/// 3
public float this[uint index]
{
get
{
return ValueOfIndex(index);
}
}
///
/// The addition operator.
///
/// The first value.
/// The second value.
/// The vector containing the result of the addition.
/// 3
public static Vector4 operator +(Vector4 arg1, Vector4 arg2)
{
return arg1.Add(arg2);
}
///
/// The subtraction operator.
///
/// The first value.
/// The second value.
/// The vector containing the result of the subtraction.
/// 3
public static Vector4 operator -(Vector4 arg1, Vector4 arg2)
{
return arg1.Subtract(arg2);
}
///
/// The unary negation operator.
///
/// The target value.
/// The vector containing the negation.
/// 3
public static Vector4 operator -(Vector4 arg1)
{
return arg1.Subtract();
}
///
/// The multiplication operator.
///
/// The first value.
/// The second value.
/// The vector containing the result of the multiplication.
/// 3
public static Vector4 operator *(Vector4 arg1, Vector4 arg2)
{
return arg1.Multiply(arg2);
}
///
/// The multiplication operator.
///
/// The first value.
/// The float value to scale the vector.
/// The vector containing the result of scaling.
/// 3
public static Vector4 operator *(Vector4 arg1, float arg2)
{
return arg1.Multiply(arg2);
}
///
/// The division operator.
///
/// The first value.
/// The second value.
/// The vector containing the result of the division.
/// 3
public static Vector4 operator /(Vector4 arg1, Vector4 arg2)
{
return arg1.Divide(arg2);
}
///
/// The division operator.
///
/// The first value.
/// The float value to scale the vector by.
/// The vector containing the result of scaling.
/// 3
public static Vector4 operator /(Vector4 arg1, float arg2)
{
return arg1.Divide(arg2);
}
///
/// Determines whether the specified object is equal to the current object.
///
/// The object to compare with the current object.
/// true if the specified object is equal to the current object; otherwise, false.
public override bool Equals(System.Object obj)
{
Vector4 vector4 = obj as Vector4;
bool equal = false;
if (X == vector4?.X && Y == vector4?.Y && Z == vector4?.Z && W == vector4?.W)
{
equal = true;
}
return equal;
}
///
/// Gets the the hash code of this Vector4.
///
/// The Hash Code.
/// 6
public override int GetHashCode()
{
return swigCPtr.Handle.GetHashCode();
}
///
/// Returns the length of the vector.
///
/// The length.
/// 3
public float Length()
{
float ret = Interop.Vector4.Vector4_Length(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Returns the length of the vector squared.
/// This is faster than using Length() when performing
/// threshold checks as it avoids use of the square root.
///
/// The length of the vector squared.
/// 3
public float LengthSquared()
{
float ret = Interop.Vector4.Vector4_LengthSquared(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Normalizes the vector.
/// Sets the vector to unit length whilst maintaining its direction.
///
/// 3
public void Normalize()
{
Interop.Vector4.Vector4_Normalize(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Clamps the vector between minimum and maximum vectors.
///
/// The minimum vector.
/// The maximum vector.
/// 3
public void Clamp(Vector4 min, Vector4 max)
{
Interop.Vector4.Vector4_Clamp(swigCPtr, Vector4.getCPtr(min), Vector4.getCPtr(max));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Vector4 obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
internal static Vector4 GetVector4FromPtr(global::System.IntPtr cPtr)
{
Vector4 ret = new Vector4(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal SWIGTYPE_p_float AsFloat()
{
global::System.IntPtr cPtr = Interop.Vector4.Vector4_AsFloat__SWIG_0(swigCPtr);
SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal float Dot(Vector3 other)
{
float ret = Interop.Vector4.Vector4_Dot__SWIG_0(swigCPtr, Vector3.getCPtr(other));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal float Dot(Vector4 other)
{
float ret = Interop.Vector4.Vector4_Dot__SWIG_1(swigCPtr, Vector4.getCPtr(other));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal float Dot4(Vector4 other)
{
float ret = Interop.Vector4.Vector4_Dot4(swigCPtr, Vector4.getCPtr(other));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal Vector4 Cross(Vector4 other)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Cross(swigCPtr, Vector4.getCPtr(other)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Dispose.
///
/// The dispose type
/// 3
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
Interop.Vector4.delete_Vector4(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
base.Dispose(type);
}
private Vector4 Add(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Add(swigCPtr, Vector4.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 AddAssign(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_AddAssign(swigCPtr, Vector4.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 Subtract(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Subtract__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 SubtractAssign(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_SubtractAssign(swigCPtr, Vector4.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 Multiply(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Multiply__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 Multiply(float rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 MultiplyAssign(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 MultiplyAssign(float rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 Divide(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Divide__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 Divide(float rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 DivideAssign(Vector4 rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_DivideAssign__SWIG_0(swigCPtr, Vector4.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 DivideAssign(float rhs)
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Vector4 Subtract()
{
Vector4 ret = new Vector4(Interop.Vector4.Vector4_Subtract__SWIG_1(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private bool EqualTo(Vector4 rhs)
{
bool ret = Interop.Vector4.Vector4_EqualTo(swigCPtr, Vector4.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private bool NotEqualTo(Vector4 rhs)
{
bool ret = Interop.Vector4.Vector4_NotEqualTo(swigCPtr, Vector4.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private float ValueOfIndex(uint index)
{
float ret = Interop.Vector4.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
}