本文整理汇总了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();
}
示例2:
// subtraction of double with Matrix
friend Matrix operator- (const double b, const Matrix& a)
{
Matrix res = -a;
res.Add(b);
return res;
}
示例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) {
//.........这里部分代码省略.........