Files
stgsharp/源代码/StgSharp/Vector/Vector.Det.cs
T

40 lines
946 B
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Math
{
public static unsafe partial class Vector
{
public static float Det(Array2x2 array)
{
return Cross(array.row1,array.row2);
}
public static unsafe float Det(Array3x3 array)
{
float* p = &array.row1.X;
Array2x2 array1 = new Array2x2(
*(p + 4), *(p + 5),
*(p + 7), *(p + 8)
);
Array2x2 array2 = new Array2x2(
*(p + 3), *(p + 5),
*(p + 6), *(p + 8)
);
Array2x2 array3 = new Array2x2(
*(p + 3), *(p + 4),
*(p + 6), *(p + 7)
);
return
*p * Det(array1)
- *(p + 1) * Det(array2)
+ *(p + 2) * Det(array3)
;
}
}
}