本文整理汇总了C++中Matrix::GetElement方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::GetElement方法的具体用法?C++ Matrix::GetElement怎么用?C++ Matrix::GetElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::GetElement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalLnr
Matrix Kinematics::CalLnr(const Matrix &rerr)
{
Matrix tem;
Matrix lnr(3,1);
float theta;
tem.MakeUnitMatrix(3);
lnr.SetElement(0,0,0);
lnr.SetElement(1,0,0);
lnr.SetElement(2,0,0);
if (rerr==tem)
{
}
else
{
theta = acos( (rerr.GetElement(0,0) + rerr.GetElement(1,1) + rerr.GetElement(2,2) -1 ) / 2 );
if (theta != theta)
{
return(lnr);
}
if (fabs(sin(theta))<EPS)
{
return(lnr);
}
lnr.SetElement(0,0, ( theta/(2*sin(theta))*(rerr.GetElement(2,1) - rerr.GetElement(1,2)) ) );
lnr.SetElement(1,0, ( theta/(2*sin(theta))*(rerr.GetElement(0,2) - rerr.GetElement(2,0)) ) );
lnr.SetElement(2,0, ( theta/(2*sin(theta))*(rerr.GetElement(1,0) - rerr.GetElement(0,1)) ) );
}
return(lnr);
}
示例2: Problem_1_C_a
void Problem_1_C_a()
{
Image imTransformer, imTransformerWarped;
int iRows = 500, iCols = 500;
string strNames[2] = {"transformmer.raw","transformer_warped.raw"};
InitImage(&imTransformer,strNames[0],iRows,iCols,3);
InitImage(&imTransformerWarped,strNames[1],iRows,iCols,3);
imTransformer.ReadImageData();
imTransformerWarped.FillColor(0);
Matrix *pmatUX[4], *pmatUX_inv[4], *pmatXU[4], *pmatTrans[4];
Point ptO1(0.5,0.5);
Point ptO2(0.5,0.0);
Point ptO3(0.3086,0.0386);
Point ptO4(0.0,0.0);
Point ptO5(0.0386,0.3086);
Point ptO6(0.0,0.5);
Point ptI1(0.5,0.5);
Point ptI2(0.5,0.0);
Point ptI3(0.25,0.00);
Point ptI4(0.00,0.00);
Point ptI5(0.00,0.25);
Point ptI6(0.0,0.5);
Point ptaOp[1][6] = {{ptO1,ptO2,ptO3,ptO4,ptO5,ptO6,}};
Point ptaIp[1][6] = {{ptI1,ptI2,ptI3,ptI4,ptI5,ptI6,}};
for(int i = 0;i<1;i++)
{
Matrix matU(6,1), matV(6,1);
Matrix matX(6,1), matY(6,1);
double dU[6] = {ptaOp[i][0].iX, ptaOp[i][1].iX, ptaOp[i][2].iX, ptaOp[i][3].iX, ptaOp[i][4].iX, ptaOp[i][5].iX};
double dV[6] = {ptaOp[i][0].iY, ptaOp[i][1].iY, ptaOp[i][2].iY, ptaOp[i][3].iY, ptaOp[i][4].iY, ptaOp[i][5].iY};
double dX[6] = {ptaIp[i][0].iX, ptaIp[i][1].iX, ptaIp[i][2].iX, ptaIp[i][3].iX, ptaIp[i][4].iX, ptaIp[i][5].iX};
double dY[6] = {ptaIp[i][0].iY, ptaIp[i][1].iY, ptaIp[i][2].iY, ptaIp[i][3].iY, ptaIp[i][4].iY, ptaIp[i][5].iY};
matU.SetElements(dU);
matV.SetElements(dV);
matX.SetElements(dX);
matY.SetElements(dY);
//
cout<<"\n";
matX.PrintMatrix();
cout<<"\n";
matY.PrintMatrix();
pmatUX[i] = Matrix::FindMatrixA(matU,matV,2);
pmatUX_inv[i] = pmatUX[i]->InverseMatrix();
//
cout<<"\n";
pmatUX_inv[i]->PrintMatrix();
Matrix *pmatA, *pmatB;
pmatA = Matrix::MatrixMultiply(*pmatUX_inv[i],matX);
pmatB = Matrix::MatrixMultiply(*pmatUX_inv[i],matY);
pmatTrans[i] = Matrix::MergeByRow(*pmatA->MatrixTranspose(),*pmatB->MatrixTranspose());
//
cout<<"\n";
pmatTrans[i]->PrintMatrix();
delete pmatA;
delete pmatB;
}
iRows = 499;
iCols = 499;
for(int i = 0;i<iRows;i++)
{
for(int j = 0;j<iCols;j++)
{
double dU = (double)(i)/499.00;
double dV = (double)(j)/499.00;
Point ptP(dU,dV);
if(ptP.LiesWithinQuarterCircle(0.5,1))
{
Matrix *pmatIp;
Matrix matOp(6,1);
matOp.SetElement(0,0,1.00);
matOp.SetElement(1,0,ptP.iX);
matOp.SetElement(2,0,ptP.iY);
matOp.SetElement(3,0,ptP.iX*ptP.iX);
matOp.SetElement(4,0,ptP.iX*ptP.iY);
matOp.SetElement(5,0,ptP.iY*ptP.iY);
pmatIp = Matrix::MatrixMultiply(*pmatTrans[0],matOp);
double dX = pmatIp->GetElement(0,0);
double dY = pmatIp->GetElement(1,0);
Pixel *pxP = imTransformer.GetPixel(dX*iRows,dY*iCols);
//.........这里部分代码省略.........
示例3: Problem_1_B
//.........这里部分代码省略.........
pmatA = Matrix::MatrixMultiply(*matTransUX_inv[i],matX);
pmatB = Matrix::MatrixMultiply(*matTransUX_inv[i],matY);
pMatTran[i] = Matrix::MergeByRow(*pmatA->MatrixTranspose(),*pmatB->MatrixTranspose());
delete pmatA;
delete pmatB;
}
iRows = 499;
iCols = 499;
for(int i = 0;i<iRows;i++)
{
for(int j = 0;j<iCols;j++)
{
double dU = (double)(i)/499.00;
double dV = (double)(j)/499.00;
Point ptP(dU,dV);
if(ptP.LiesWithinTriangle(ptaOp[0]))
{
//Check for Triangle_1
Matrix *pmatIp;
Matrix matOp(3,1);
matOp.SetElement(0,0,1.00);
matOp.SetElement(1,0,ptP.iX);
matOp.SetElement(2,0,ptP.iY);
pmatIp = Matrix::MatrixMultiply(*pMatTran[0],matOp);
double dX = pmatIp->GetElement(0,0);
double dY = pmatIp->GetElement(1,0);
Pixel *pxP = imCowboy.GetPixel(dX*iRows,dY*iCols);
imCowboyWarped.SetPixel(i,j,*pxP);
//imTestImgae_1_Warped.SetPixel(i,j,*pxP);
delete pxP;
delete pmatIp;
}
else if(ptP.LiesWithinTriangle(ptaOp[1]))
{
//Check for Triangle_2
Matrix *pmatIp;
Matrix matOp(3,1);
matOp.SetElement(0,0,1.00);
matOp.SetElement(1,0,ptP.iX);
matOp.SetElement(2,0,ptP.iY);
pmatIp = Matrix::MatrixMultiply(*pMatTran[1],matOp);
double dX = pmatIp->GetElement(0,0);
double dY = pmatIp->GetElement(1,0);
Pixel *pxP = imCowboy.GetPixel(dX*iRows,dY*iCols);
imCowboyWarped.SetPixel(i,j,*pxP);
delete pxP;
delete pmatIp;
}
else if(ptP.LiesWithinTriangle(ptaOp[2]))
{
示例4: Problem_1_A
//.........这里部分代码省略.........
ptaT7[2].iY = 0.25;
ptaT8[0].iX = 0.50;
ptaT8[0].iY = 0.00;
ptaT8[1].iX = 0.25;
ptaT8[1].iY = 0.25;
ptaT8[2].iX = 0.50;
ptaT8[2].iY = 0.50;
iRows = 499;
iCols = 499;
for(int i = 0;i<iRows;i++)
{
for(int j = 0;j<iCols;j++)
{
double dU = (double)(i)/499.00;
double dV = (double)(j)/499.00;
Point ptP(dU,dV);
if(ptP.LiesWithinTriangle(ptaT1))
{
//Check for Triangle_1
Matrix *pmatIp;
Matrix matOp(3,1);
matOp.SetElement(0,0,1.00);
matOp.SetElement(1,0,ptP.iX);
matOp.SetElement(2,0,ptP.iY);
pmatIp = Matrix::MatrixMultiply(matTrans1,matOp);
double dX = pmatIp->GetElement(0,0);
double dY = pmatIp->GetElement(1,0);
Pixel *pxP = imPuppy.GetPixel(dX*iRows,dY*iCols);
imPuppyWarped.SetPixel(i,j,*pxP);
imTestImgae_1_Warped.SetPixel(i,j,*pxP);
delete pxP;
delete pmatIp;
}
else if(ptP.LiesWithinTriangle(ptaT2))
{
//Check for Triangle_2
Matrix *pmatIp;
Matrix matOp(3,1);
matOp.SetElement(0,0,1.00);
matOp.SetElement(1,0,ptP.iX);
matOp.SetElement(2,0,ptP.iY);
pmatIp = Matrix::MatrixMultiply(matTrans2,matOp);
double dX = pmatIp->GetElement(0,0);
double dY = pmatIp->GetElement(1,0);
Pixel *pxP = imPuppy.GetPixel(dX*iRows,dY*iCols);
imPuppyWarped.SetPixel(i,j,*pxP);
imTestImgae_1_Warped.SetPixel(i,j,*pxP);
delete pxP;
delete pmatIp;
}
else if(ptP.LiesWithinTriangle(ptaT3))
示例5:
TEST(MatrixTests, ShouldCalculatePerspectiveProjectionMatrix)
{
Matrix projectionMatrix = Matrix::CreatePerspectiveProjectionMatrix2(0.78, 1, 0.01, 1.0);
EXPECT_NEAR(2.432765, projectionMatrix.GetElement(0, 0), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(0, 1), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(0, 2), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(0, 3), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(1, 0), 0.000001);
EXPECT_NEAR(2.432765, projectionMatrix.GetElement(1, 1), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(1, 2), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(1, 3), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(2, 0), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(2, 1), 0.000001);
EXPECT_NEAR(-1.010101, projectionMatrix.GetElement(2, 2), 0.000001);
EXPECT_NEAR(-1, projectionMatrix.GetElement(2, 3), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(3, 0), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(3, 1), 0.000001);
EXPECT_NEAR(-0.01010101, projectionMatrix.GetElement(3, 2), 0.000001);
EXPECT_NEAR(0, projectionMatrix.GetElement(3, 3), 0.000001);
}
示例6: Vector
TEST(MatrixTests, ShouldCalculateViewMatrix)
{
Matrix viewMatrix = Matrix::CreateViewMatrix(Vector(0, 0, -10), Vector(0, 0, 0), Vector(0, 1, 0));
EXPECT_NEAR(-1, viewMatrix.GetElement(0, 0), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(0, 1), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(0, 2), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(0, 3), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(1, 0), 0.000001);
EXPECT_NEAR(1, viewMatrix.GetElement(1, 1), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(1, 2), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(1, 3), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(2, 0), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(2, 1), 0.000001);
EXPECT_NEAR(-1, viewMatrix.GetElement(2, 2), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(2, 3), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(3, 0), 0.000001);
EXPECT_NEAR(0, viewMatrix.GetElement(3, 1), 0.000001);
EXPECT_NEAR(10, viewMatrix.GetElement(3, 2), 0.000001);
EXPECT_NEAR(1, viewMatrix.GetElement(3, 3), 0.000001);
}