当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix2f::transpose方法代码示例

本文整理汇总了C++中Matrix2f::transpose方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix2f::transpose方法的具体用法?C++ Matrix2f::transpose怎么用?C++ Matrix2f::transpose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix2f的用法示例。


在下文中一共展示了Matrix2f::transpose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rotateCovariance

Matrix2f TeamPlayersLocator::rotateCovariance(const Matrix2f& matrix, const float angle)
{
  const float cosine = std::cos(angle);
  const float sine = std::sin(angle);
  const Matrix2f rotationMatrix = (Matrix2f() << cosine, -sine, sine, cosine).finished();
  return (rotationMatrix * matrix) * rotationMatrix.transpose();
}
开发者ID:Yanzqing,项目名称:BHumanCodeRelease,代码行数:7,代码来源:TeamPlayersLocator.cpp

示例2: matrix

void matrix() {
	{ // matrix multiplication
		const Matrix<5, 3, float> a(0.0, 0.5, 1.0,
		                            1.5, 2.0, 2.5,
		                            3.0, 3.5, 4.0,
		                            4.5, 5.0, 5.5,
		                            6.0, 6.5, 7.0);
		const Matrix<3, 4, float> b(1, 0, 0, 0,
		                            0, 1, 0, 0,
		                            0, 0, 1, 0);
		Matrix<5, 4, float> c = a * b;
		TESTEQUALS_FLOAT(c[0][0], 0, 1e-7);
		TESTEQUALS_FLOAT(c[0][1], 0.5, 1e-7);
		TESTEQUALS_FLOAT(c[0][2], 1, 1e-7);
		TESTEQUALS_FLOAT(c[0][3], 0, 1e-7);
		TESTEQUALS_FLOAT(c[1][0], 1.5, 1e-7);
		TESTEQUALS_FLOAT(c[1][1], 2, 1e-7);
		TESTEQUALS_FLOAT(c[1][2], 2.5, 1e-7);
		TESTEQUALS_FLOAT(c[1][3], 0, 1e-7);
		TESTEQUALS_FLOAT(c[2][0], 3, 1e-7);
		TESTEQUALS_FLOAT(c[2][1], 3.5, 1e-7);
		TESTEQUALS_FLOAT(c[2][2], 4, 1e-7);
		TESTEQUALS_FLOAT(c[2][3], 0, 1e-7);
		TESTEQUALS_FLOAT(c[3][0], 4.5, 1e-7);
		TESTEQUALS_FLOAT(c[3][1], 5, 1e-7);
		TESTEQUALS_FLOAT(c[3][2], 5.5, 1e-7);
		TESTEQUALS_FLOAT(c[3][3], 0, 1e-7);
		TESTEQUALS_FLOAT(c[4][0], 6, 1e-7);
		TESTEQUALS_FLOAT(c[4][1], 6.5, 1e-7);
		TESTEQUALS_FLOAT(c[4][2], 7, 1e-7);
		TESTEQUALS_FLOAT(c[4][3], 0, 1e-7);
	}

	{ // addition and subtraction
		const Matrix2f a(1, 2, 3, 4);
		const Matrix2f b(5, 6, 7, 8);
		Matrix2f c = a + b;
		TESTEQUALS_FLOAT(c[0][0], 6, 1e-7);
		TESTEQUALS_FLOAT(c[0][1], 8, 1e-7);
		TESTEQUALS_FLOAT(c[1][0], 10, 1e-7);
		TESTEQUALS_FLOAT(c[1][1], 12, 1e-7);

		c = b - a;
		TESTEQUALS_FLOAT(c[0][0], 4, 1e-7);
		TESTEQUALS_FLOAT(c[0][1], 4, 1e-7);
		TESTEQUALS_FLOAT(c[1][0], 4, 1e-7);
		TESTEQUALS_FLOAT(c[1][1], 4, 1e-7);
	}

	{ // scalar multiplication and division
		const Matrix2f a(0, 1, 2, 3);
		Matrix2f b = a * 2;
		TESTEQUALS_FLOAT(b[0][0], 0, 1e-7);
		TESTEQUALS_FLOAT(b[0][1], 2, 1e-7);
		TESTEQUALS_FLOAT(b[1][0], 4, 1e-7);
		TESTEQUALS_FLOAT(b[1][1], 6, 1e-7);

		b = 2 * a;
		TESTEQUALS_FLOAT(b[0][0], 0, 1e-7);
		TESTEQUALS_FLOAT(b[0][1], 2, 1e-7);
		TESTEQUALS_FLOAT(b[1][0], 4, 1e-7);
		TESTEQUALS_FLOAT(b[1][1], 6, 1e-7);

		b = a / 0.5;
		TESTEQUALS_FLOAT(b[0][0], 0, 1e-7);
		TESTEQUALS_FLOAT(b[0][1], 2, 1e-7);
		TESTEQUALS_FLOAT(b[1][0], 4, 1e-7);
		TESTEQUALS_FLOAT(b[1][1], 6, 1e-7);
	}

	{ // transposition
		const Matrix2f a(1, 2, 3, 4);
		const Matrix2f b = a.transpose();
		TESTEQUALS_FLOAT(b[0][0], 1, 1e-7);
		TESTEQUALS_FLOAT(b[0][1], 3, 1e-7);
		TESTEQUALS_FLOAT(b[1][0], 2, 1e-7);
		TESTEQUALS_FLOAT(b[1][1], 4, 1e-7);
	}

	{ // vector interaction
		const Matrix3f a(2, 0, 0,
		                 0, 2, 0,
		                 0, 0, 2);
		const Vector3f v(1, 2, 3);
		auto u = (a * v).to_vector();
		TESTEQUALS_FLOAT(u[0], 2, 1e-7);
		TESTEQUALS_FLOAT(u[1], 4, 1e-7);
		TESTEQUALS_FLOAT(u[2], 6, 1e-7);
	}
}
开发者ID:SFTtech,项目名称:openage,代码行数:90,代码来源:matrix_test.cpp

示例3:

Matrix2f M = Matrix2f::Random();
Matrix2f m;
m = M;
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Now we want to replace m by its own transpose." << endl;
cout << "If we do m = m.transpose(), then m becomes:" << endl;
m = m.transpose();
cout << m << endl << "which is wrong!" << endl;
cout << "Now let us instead do m = m.transpose().eval(). Then m becomes" << endl;
m = M;
m = m.transpose().eval();
cout << m << endl << "which is right." << endl;
开发者ID:OSVR,项目名称:eigen-kalman,代码行数:12,代码来源:MatrixBase_eval.cpp


注:本文中的Matrix2f::transpose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。