89 lines
2.4 KiB
C#
89 lines
2.4 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace StgSharp.Math
|
|
{
|
|
public class Matrix3x2
|
|
{
|
|
internal M128Map _map;
|
|
|
|
internal IntPtr _colum0Ptr;
|
|
internal IntPtr _colum1Ptr;
|
|
|
|
private bool _isTransposed;
|
|
private Matrix2x3 _transpose;
|
|
|
|
public Matrix3x2(
|
|
float a00,float a01,
|
|
float a10,float a11,
|
|
float a20,float a21
|
|
)
|
|
{
|
|
_colum0Ptr = internalIO.load_internal(a00,a10,a20,0);
|
|
_colum0Ptr = internalIO.load_internal(a01,a11,a21,0);
|
|
|
|
_transpose = new Matrix2x3(this);
|
|
}
|
|
|
|
internal Matrix3x2(
|
|
IntPtr colum0Ptr,
|
|
IntPtr colum1Ptr
|
|
)
|
|
{
|
|
_colum0Ptr = colum0Ptr;
|
|
_colum1Ptr = colum1Ptr;
|
|
|
|
_transpose = new Matrix2x3(this);
|
|
}
|
|
|
|
internal Matrix3x2(Matrix2x3 transpose)
|
|
{
|
|
_transpose = transpose;
|
|
}
|
|
|
|
public unsafe Matrix2x3 Transpose(TransposeMode transposeMode)
|
|
{
|
|
if (_isTransposed)
|
|
{
|
|
(*(M128*)_transpose._colum0Ptr).single_0 = (*(M128*)_colum0Ptr).single_0;
|
|
(*(M128*)_transpose._colum1Ptr).single_0 = (*(M128*)_colum0Ptr).single_1;
|
|
(*(M128*)_transpose._colum2Ptr).single_0 = (*(M128*)_colum0Ptr).single_2;
|
|
|
|
(*(M128*)_transpose._colum0Ptr).single_1 = (*(M128*)_colum1Ptr).single_0;
|
|
(*(M128*)_transpose._colum1Ptr).single_1 = (*(M128*)_colum1Ptr).single_1;
|
|
(*(M128*)_transpose._colum2Ptr).single_1 = (*(M128*)_colum1Ptr).single_2;
|
|
|
|
_isTransposed = true;
|
|
|
|
}
|
|
switch (transposeMode)
|
|
{
|
|
case TransposeMode.New:
|
|
return new Matrix2x3(
|
|
_transpose._colum0Ptr,
|
|
_transpose._colum0Ptr,
|
|
_transpose._colum0Ptr
|
|
);
|
|
break;
|
|
case TransposeMode.Copy:
|
|
return _transpose;
|
|
break;
|
|
default:
|
|
throw new Exception();
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
~Matrix3x2()
|
|
{
|
|
if (_map==null)
|
|
{
|
|
internalIO.deinitM128_internal(_colum0Ptr);
|
|
internalIO.deinitM128_internal(_colum1Ptr);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|