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


C++ Matrix::Add方法代码示例

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


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

示例1: DrawBinded

void ColoredPolygon::DrawBinded()
{
    _trianglesBinded = _triangles;
    Matrix tmp;
    for (uint i = 0; i < _trianglesBinded.GetVB().Size(); ++i)
    {
        bool needMul = false;
        tmp.Zero();
        if (_dots[i].p[0].bone)
        {
            tmp.Add(_dots[i].p[0].bone->GetAnimVertMatrix(), _dots[i].p[0].mass);
            needMul = true;
        }
        if (_dots[i].p[1].bone)
        {
            tmp.Add(_dots[i].p[1].bone->GetAnimVertMatrix(), _dots[i].p[1].mass);
        }
        if (needMul)
            tmp.Mul(_trianglesBinded.GetVB().VertXY(i));
    }

    Render::PushColorAndMul(_color);
    _trianglesBinded.Render();
    Render::PopColor();
}
开发者ID:RandomAmbersky,项目名称:codeanimator,代码行数:25,代码来源:ColoredPolygon.cpp

示例2:

 // subtraction of double with Matrix
 friend Matrix operator- (const double b, const Matrix& a)
 {
   Matrix res = -a;
   res.Add(b);
   return res;
 }
开发者ID:cnjoroge,项目名称:slam,代码行数:7,代码来源:matrix.cpp

示例3: main

int main() {
	// Creation test
	Matrix<double> m = Matrix<double>(4, 3);
	Matrix<double> n = Matrix<double>(m);

	// Width, Height test
	if (m.height() == 4 && m.width() == 3 && m.size == 12) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " .height(), .width() and .size" << endl;

	// Assignment test
	m(1, 1) = 1.0;
	if (m(1, 1) == 1.0) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Assignment by ()" << endl;

	Matrix<double> m2 = Matrix<double>(3, 2);
	m2(3, 1) = 2.0;

	// Duplication test
	Matrix<double> m_ = Matrix<double>(m);
	if (m_(1, 1) == 1.0) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Duplicate" << endl;

	if (m.Equal(m_)) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Equal" << endl;

	// Mat-Mat Addition test
	m_(2, 2) = 3.0;
	m.Add(m_);
	if (m(1, 1) == 2.0 && m(2, 2) == 3.0) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Matrix-by-matrix Add" << endl;

	// Mat-Mat + test
	n = m + m_;
	if (n(1, 1) == 3.0 && n(2, 2) == 6.0) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Matrix-by-matrix Add with +" << endl;

	// Mat-Mat Subtraction test
	m.Sub(m_);
	if (m(1, 1) == 1.0 && m(2, 2) == 0.0) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Matrix-by-matrix Sub" << endl;

	// Mat-Mat - test
	n = m_ - m - m;
	if (n(1, 1) == -1.0 && n(2, 2) == 3.0) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Matrix-by-matrix Sub with -" << endl;

	// Mat-Mat Multiplication test
	m(2, 3) = 9.0;
	m2(1, 1) = 5.0;
	n = m.Mult(m2);
	if (n(1, 1) == 5.0 && n(2, 1) == 18) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Matrix-by-matrix Mult" << endl;

	// Mat-Mat * test
	n = m * m2;
	if (n(1, 1) == 5.0 && n(2, 1) == 18) {
		cout << "[PASS]";
	} else {
		cout << "[FAIL]";
	}
	cout << " Matrix-by-matrix Mult with *" << endl;

	// Mat-T Addition test
	if (m(1, 1) == 1.0 && m(2, 3) == 9.0) {
//.........这里部分代码省略.........
开发者ID:henryYunhui,项目名称:matrix,代码行数:101,代码来源:tests.cpp


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