use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestPnPInfinitesimalPlanePoseEstimation method constructR.
@Test
void constructR() {
Equation eq = new Equation();
eq.process("R_v=randn(3,3)");
eq.process("R22=[1 2;3 4]");
eq.process("c=[1.1;2.1]");
eq.process("a=3.1");
eq.process("b=[-0.4;0.2]");
eq.process("R1=R_v*[R22 c;b' a]");
eq.process("R2=R_v*[R22, -c;-b', a]");
DMatrixRMaj found = new DMatrixRMaj(3, 3);
DMatrixRMaj R_v = eq.lookupDDRM("R_v");
DMatrix2x2 R22 = new DMatrix2x2();
DConvertMatrixStruct.convert(eq.lookupDDRM("R22"), R22);
Vector3D_F64 ca = new Vector3D_F64(1.1, 2.1, 3.1);
PnPInfinitesimalPlanePoseEstimation.constructR(found, R_v, R22, -0.4, 0.2, ca, 1, new DMatrixRMaj(3, 3));
assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("R1"), found, UtilEjml.TEST_F64));
PnPInfinitesimalPlanePoseEstimation.constructR(found, R_v, R22, -0.4, 0.2, ca, -1, new DMatrixRMaj(3, 3));
assertTrue(MatrixFeatures_DDRM.isIdentical(eq.lookupDDRM("R2"), found, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestPnPInfinitesimalPlanePoseEstimation method compute_Rv.
@Test
void compute_Rv() {
Equation eq = new Equation();
eq.process("v=[1.1,0.5]'");
eq.process("t=normF(v)");
eq.process("s=normF([v',1]')");
eq.process("cosT=1.0/s");
eq.process("sinT=sqrt(1-1.0/s^2)");
eq.process("Kx=(1.0/t)*[[0 0;0 0] v;-v' 0]");
eq.process("R_v = eye(3) + sinT*Kx + (1.0-cosT)*Kx*Kx");
PnPInfinitesimalPlanePoseEstimation alg = new PnPInfinitesimalPlanePoseEstimation();
DMatrixRMaj V = eq.lookupDDRM("v");
alg.v1 = V.get(0);
alg.v2 = V.get(1);
alg.compute_Rv();
DMatrixRMaj expected_R_v = eq.lookupDDRM("R_v");
assertTrue(MatrixFeatures_DDRM.isEquals(expected_R_v, alg.R_v, UtilEjml.TEST_F64));
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestPnPInfinitesimalPlanePoseEstimation method compute_B.
@Test
void compute_B() {
Equation eq = new Equation();
eq.process("v=[1.1,0.5]'");
eq.process("R_v=[1,2,3;4,5,6;7,8,9]'");
eq.process("B=[eye(2),-v]*R_v");
DMatrixRMaj v = eq.lookupDDRM("v");
DMatrixRMaj R_v = eq.lookupDDRM("R_v");
DMatrixRMaj expected = eq.lookupDDRM("B");
double v1 = v.get(0);
double v2 = v.get(1);
DMatrix2x2 B = new DMatrix2x2();
PnPInfinitesimalPlanePoseEstimation.compute_B(B, R_v, v1, v2);
assertEquals(expected.get(0, 0), B.a11, UtilEjml.TEST_F64);
assertEquals(expected.get(0, 1), B.a12, UtilEjml.TEST_F64);
assertEquals(expected.get(1, 0), B.a21, UtilEjml.TEST_F64);
assertEquals(expected.get(1, 1), B.a22, UtilEjml.TEST_F64);
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestHomographyTotalLeastSquares method backsubstitution0134.
@Test
void backsubstitution0134() {
int N = 10;
SimpleMatrix Pp = SimpleMatrix.random_DDRM(2, N, -1, 1, rand);
SimpleMatrix P = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
SimpleMatrix X = SimpleMatrix.random_DDRM(N, 2, -1, 1, rand);
double[] H = new double[9];
H[6] = 0.4;
H[7] = 0.8;
H[8] = -0.3;
Equation eq = new Equation();
eq.alias(P.copy(), "P", Pp.copy(), "Pp", X.copy(), "X", N, "N");
eq.process("H=[0.4;0.8;-0.3]");
eq.process("Ax = -Pp*diag(-X(:,0))*[P,ones(N,1)]*H");
eq.process("Ay = -Pp*diag(-X(:,1))*[P,ones(N,1)]*H");
HomographyTotalLeastSquares.backsubstitution0134(Pp.getMatrix(), P.getMatrix(), X.getMatrix(), H);
DMatrixRMaj Ax = eq.lookupDDRM("Ax");
DMatrixRMaj Ay = eq.lookupDDRM("Ay");
assertEquals(Ax.data[0], H[0], UtilEjml.TEST_F64);
assertEquals(Ax.data[1], H[1], UtilEjml.TEST_F64);
assertEquals(Ay.data[0], H[3], UtilEjml.TEST_F64);
assertEquals(Ay.data[1], H[4], UtilEjml.TEST_F64);
}
use of org.ejml.equation.Equation in project BoofCV by lessthanoptimal.
the class TestDecomposeAbsoluteDualQuadratic method recomputeQ.
@Test
void recomputeQ() {
Equation eq = new Equation();
eq.process("k = [300 3, 204;0 230 400; 0 0 1]").process("w = k*k'").process("p=[2.1;0.4;-0.3]").process("Q=[w , -w*p;-p'*w, p'*w*p]");
DecomposeAbsoluteDualQuadratic alg = new DecomposeAbsoluteDualQuadratic();
DConvertMatrixStruct.convert(eq.lookupDDRM("k"), alg.getK());
DConvertMatrixStruct.convert(eq.lookupDDRM("p"), alg.getP());
DMatrix4x4 found = new DMatrix4x4();
alg.recomputeQ(found);
DMatrixRMaj Q = eq.lookupDDRM("Q");
assertTrue(MatrixFeatures_D.isIdentical(Q, found, UtilEjml.TEST_F64));
}
Aggregations