Port MSCKF complete (from now)
This commit is contained in:
parent
b10929619d
commit
c1b9a8c5e6
@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Vector3 = UnityEngine.Vector3;
|
using Vector3 = UnityEngine.Vector3;
|
||||||
using Vector2 = UnityEngine.Vector2;
|
using Vector2 = UnityEngine.Vector2;
|
||||||
|
using Quaternion = UnityEngine.Quaternion;
|
||||||
|
|
||||||
public readonly struct Slice {
|
public readonly struct Slice {
|
||||||
public uint start { get; }
|
public uint start { get; }
|
||||||
@ -216,7 +217,7 @@ public class Matrix2 {
|
|||||||
public Matrix2 Slice(Slice rowRange, Slice colRange) {
|
public Matrix2 Slice(Slice rowRange, Slice colRange) {
|
||||||
return Slice((rowRange.start, rowRange.stop), (colRange.start, colRange.stop));
|
return Slice((rowRange.start, rowRange.stop), (colRange.start, colRange.stop));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Matrix2 Slice((uint start, uint stop) rowRange, (uint start, uint stop) colRange) {
|
public Matrix2 Slice((uint start, uint stop) rowRange, (uint start, uint stop) colRange) {
|
||||||
float[,] result = new float[rowRange.stop - rowRange.start, colRange.stop - colRange.start];
|
float[,] result = new float[rowRange.stop - rowRange.start, colRange.stop - colRange.start];
|
||||||
|
|
||||||
@ -374,6 +375,15 @@ public class Matrix1 {
|
|||||||
return new Matrix1(result);
|
return new Matrix1(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Matrix1 FromQuaternion(Quaternion q) {
|
||||||
|
float[] result = new float[4];
|
||||||
|
result[0] = q.x;
|
||||||
|
result[1] = q.y;
|
||||||
|
result[2] = q.z;
|
||||||
|
result[3] = q.w;
|
||||||
|
return new Matrix1(result);
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 vector2 {
|
public Vector2 vector2 {
|
||||||
get {
|
get {
|
||||||
if (this.magnitude != 2)
|
if (this.magnitude != 2)
|
||||||
@ -388,6 +398,13 @@ public class Matrix1 {
|
|||||||
return new Vector3(this.data[0], this.data[1], this.data[2]);
|
return new Vector3(this.data[0], this.data[1], this.data[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Quaternion quaternion {
|
||||||
|
get {
|
||||||
|
if (this.magnitude != 4)
|
||||||
|
throw new System.ArgumentException("Matrix1 must be of size 4");
|
||||||
|
return new Quaternion(this.data[0], this.data[1], this.data[2], this.data[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Matrix2 Transpose() {
|
public Matrix2 Transpose() {
|
||||||
float[,] r = new float[1, this.magnitude];
|
float[,] r = new float[1, this.magnitude];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user