Skip to content

Commit

Permalink
[NUI][WIP] White comments for Matrix
Browse files Browse the repository at this point in the history
Signed-off-by: Eunki, Hong <[email protected]>
  • Loading branch information
Eunki, Hong committed Jun 26, 2023
1 parent 17a5183 commit 0a09027
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
78 changes: 71 additions & 7 deletions src/Tizen.NUI/src/public/Common/Matrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,116 @@
using System.ComponentModel;

namespace Tizen.NUI
{ /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
{
/// <summary>
/// The Matrix class represents transformations and projections. <br/>
/// The matrix is stored as a flat array and is Column Major, i.e. the storage order is as follows (numbers represent indices of array): <br/>
/// <code>
/// 0 4 8 12
/// 1 5 9 13
/// 2 6 10 14
/// 3 7 11 15
/// </code>
/// Each axis is contiguous in memory, so the x-axis corresponds to elements 0, 1, 2 and 3, the y-axis corresponds to
/// elements 4, 5, 6, 7, the z-axis corresponds to elements 12, 13, 14 and 15, and the translation vector corresponds to
/// elements 12, 13 and 14.
/// </summary>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class Matrix : Disposable
{
internal Matrix(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
}

/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.Matrix.DeleteMatrix(swigCPtr);
}

/// <summary>
/// The constructor initialized as zero.
/// </summary>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Matrix() : this(Interop.Matrix.NewMatrix(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// The constructor whether initialize matrix or not.
/// </summary>
/// <param name="initialize">True if we want to initialize values as zero. False if we just allocate and do not initalize value.</param>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Matrix(bool initialize) : this(Interop.Matrix.NewMatrix(initialize), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// The constructor with continuous float array.
/// </summary>
/// <param name="array">Array of float value.</param>
/// <remark>
/// Please note that NUI using column major matrix.
/// </remark>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Matrix(float[] array) : this(Interop.Matrix.NewMatrix(array), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// The constructor with Rotation to be rotation transform matrix.
/// </summary>
/// <param name="rotation">Rotation information.</param>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Matrix(Rotation rotation) : this(Interop.Matrix.NewMatrixQuaternion(Rotation.getCPtr(rotation)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

/// <summary>
/// The constructor.
/// </summary>
/// <param name="matrix">Matrix to create this matrix from</param>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public Matrix(Matrix matrix) : this(Interop.Matrix.NewMatrix(Matrix.getCPtr(matrix)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}

public Matrix Assign(Matrix matrix)
/// <summary>
/// Assign.
/// </summary>
/// <param name="rhs">A reference to the copied handle.</param>
/// <returns>A reference to this.</returns>
internal Matrix Assign(Matrix rhs)
{
Matrix ret = new Matrix(Interop.Matrix.Assign(SwigCPtr, Matrix.getCPtr(matrix)), false);
Matrix ret = new Matrix(Interop.Matrix.Assign(SwigCPtr, Matrix.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public static Matrix IDENTITY
/// <summary>
/// The matrix as identity
/// </summary>
/// <code>
/// [[1, 0, 0, 0],
/// [0, 1, 0, 0],
/// [0, 0, 1, 0],
/// [0, 0, 0, 1]]
/// </code>
/// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public static Matrix Identity
{
get
{
Expand Down Expand Up @@ -137,21 +201,21 @@ public void Transpose()

public Vector3 GetXAxis()
{
Vector3 ret = new Vector3(Interop.Matrix.GetXAxis(SwigCPtr), true);
Vector3 ret = new Vector3(Interop.Matrix.GetXAxis(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public Vector3 GetYAxis()
{
Vector3 ret = new Vector3(Interop.Matrix.GetYAxis(SwigCPtr), true);
Vector3 ret = new Vector3(Interop.Matrix.GetYAxis(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}

public Vector3 GetZAxis()
{
Vector3 ret = new Vector3(Interop.Matrix.GetZAxis(SwigCPtr), true);
Vector3 ret = new Vector3(Interop.Matrix.GetZAxis(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Tizen.NUI/src/public/Common/Matrix3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ internal Matrix3(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemo
{
}

/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.Matrix.DeleteMatrix3(swigCPtr);
Expand Down

0 comments on commit 0a09027

Please sign in to comment.