/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
auto floor = [&](float aValue, int aDecimal) { constint digit = pow(10, aDecimal); constfloat result = (int)(aValue * digit); return result / digit;
};
// Test rotate 45 degree on x-axis.
gfx::Quaternion expectedOrient(0.382f, 0.0f, 0.0f, 0.923f);
transformMatrix.RotateX(0.785f); // the orient would be (x:0.3825, y:0, z:0, w: 0.9239)
transformMatrix.Decompose(trans, orient, scale);
EXPECT_EQ(floor(orient.x, 3), expectedOrient.x);
EXPECT_EQ(floor(orient.y, 3), expectedOrient.y);
EXPECT_EQ(floor(orient.z, 3), expectedOrient.z);
EXPECT_EQ(floor(orient.w, 3), expectedOrient.w);
// Test set rotate matrix from a quaternion and // compare it with the result from decompose.
transformMatrix = gfx::Matrix4x4();
transformMatrix.SetRotationFromQuaternion(orient);
transformMatrix.Decompose(trans, orient, scale);
EXPECT_EQ(floor(orient.x, 3), expectedOrient.x);
EXPECT_EQ(floor(orient.y, 3), expectedOrient.y);
EXPECT_EQ(floor(orient.z, 3), expectedOrient.z);
EXPECT_EQ(floor(orient.w, 3), expectedOrient.w);
// Test rotate -45 degree on axis: (0.577f, 0.577f, 0.577f).
transformMatrix = gfx::Matrix4x4();
transformMatrix.SetRotateAxisAngle(0.577f, 0.577f, 0.577f, -0.785f); // the orient would be (x:-0.2208, y:-0.2208, z:-0.2208, w: 0.9239)
transformMatrix.Decompose(trans, orient, scale);
// Test set rotate matrix from a quaternion and // compare it with the result from decompose.
transformMatrix = gfx::Matrix4x4();
transformMatrix.SetRotationFromQuaternion(orient);
transformMatrix.Decompose(trans, orient, scale);
EXPECT_EQ(floor(orient.x, 3), expectedOrient.x);
EXPECT_EQ(floor(orient.y, 3), expectedOrient.y);
EXPECT_EQ(floor(orient.z, 3), expectedOrient.z);
EXPECT_EQ(floor(orient.w, 3), expectedOrient.w);
}
TEST(Matrix4x4Flagged, Mult)
{
Matrix4x4Flagged simple =
Matrix4x4::Translation(Point(42, 42)) * Matrix4x4::Scaling(3, 3, 1); // For the general matrix, put a value in every field to make sure // nothing gets dropped.
Matrix4x4 general(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2);
// Use Matrix4x4::operator*(Matrix4x4). // For the purposes of this test, assume that's correct.
Matrix4x4Flagged realResult = Matrix4x4Flagged(simple.GetMatrix() * general);
// Check that Matrix4x4Flagged::operator*(Matrix4x4Flagged) produces the same // result.
Matrix4x4Flagged flaggedResult = simple * Matrix4x4Flagged(general);
EXPECT_EQ(realResult, flaggedResult);
// Check that Matrix4x4Flagged::operator*(Matrix4x4) produces the same result.
Matrix4x4Flagged mixedResult = simple * general;
EXPECT_EQ(realResult, mixedResult);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.