本文整理汇总了C++中Mat4f::getZ方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4f::getZ方法的具体用法?C++ Mat4f::getZ怎么用?C++ Mat4f::getZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4f
的用法示例。
在下文中一共展示了Mat4f::getZ方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dir
void m3dTest::gramSchmidtTest()
{
using namespace m3d;
Vec3f dir(frand(), frand(), frand());
Vec3f pos(frand(), frand(), frand());
Mat4f matrix = Mat4f::gramSchmidt(dir, pos);
// check if all axes are perpendicular
CPPUNIT_ASSERT(fabs(matrix.getX() * matrix.getY()) < EPSILON);
CPPUNIT_ASSERT(fabs(matrix.getY() * matrix.getZ()) < EPSILON);
CPPUNIT_ASSERT(fabs(matrix.getX() * matrix.getZ()) < EPSILON);
CPPUNIT_ASSERT(fabs(matrix.getX().len() - 1.0f) < EPSILON);
CPPUNIT_ASSERT(fabs(matrix.getY().len() - 1.0f) < EPSILON);
CPPUNIT_ASSERT(fabs(matrix.getZ().len() - 1.0f) < EPSILON);
for (int x = 0; x < 4; ++x) {
for (int y = 0; y < 4; ++y) {
// check for NaN
CPPUNIT_ASSERT(matrix[x][y] == matrix[x][y]);
}
}
// check if position is correct
CPPUNIT_ASSERT(matrix.getW() == pos);
}
示例2: axis
void m3dTest::quaternionTest()
{
using namespace m3d;
// generate first matrix and quaternion
Vec3f axis(frand(), frand(), frand());
float angle = frand(0, 2.0f*PI);
Mat4f input1 = Mat4f::rotAxis(axis, angle);
Quatf quat1(axis, angle);
// generate second matrix and quaternion
Vec3f axis2(frand(), frand(), frand());
float angle2 = frand(0, 2.0f*PI);
Mat4f input2 = Mat4f::rotAxis(axis2, angle2);
Quatf quat2(axis2, angle2);
// multiply them
Mat4f input = input1 * input2;
Quatf quat = quat1 * quat2;
Mat4f output = quat.mat4();
// normalize all axes
input.setX(input.getX().normalized());
input.setY(input.getY().normalized());
input.setZ(input.getZ().normalized());
output.setX(input.getX().normalized());
output.setY(input.getY().normalized());
output.setZ(input.getZ().normalized());
// compare
for (int x = 0; x < 4; ++x) {
for (int y = 0; y < 4; ++y) {
// check if equal, allow a reasonable deviation
CPPUNIT_ASSERT(fabs(input[x][y] - output[x][y]) < EPSILON);
// check for NaN
CPPUNIT_ASSERT(output[x][y] == output[x][y]);
}
}
}