Exemple #1
0
static int
test_inverse (const vec3_t angles, const vec3_t scale)
{
	int         i;
	quat_t      rotation;
	mat3_t      mat, inv, I, res;

	AngleQuat (angles, rotation);
	Mat3Init (rotation, scale, mat);

	Mat3Identity (I);
	Mat3Inverse (mat, inv);
	Mat3Mult (mat, inv, res);

	for (i = 0; i < 3 * 3; i++)
		if (!compare (I[i], res[i]))
			goto fail;

	return 1;
fail:
	printf ("\n\n(%g %g %g) (%g %g %g)\n",
			VectorExpand (angles), VectorExpand (scale));
	printf ("  [%g %g %g]\n  [%g %g %g]\n  [%g %g %g]\n\n", Mat3Expand (mat));
	printf ("  [%g %g %g]\n  [%g %g %g]\n  [%g %g %g]\n\n", Mat3Expand (inv));
	printf ("  [%g %g %g]\n  [%g %g %g]\n  [%g %g %g]\n\n", Mat3Expand (res));
	return 0;
}
Exemple #2
0
	//--------------------------------------------------------------------------------------------------------------
	//获取反矩阵
	Matrix3 Matrix3::GetInverse() const
	{
		static Matrix3 tmp;
		Mat3Inverse( &tmp, this );
		return tmp;
	}
Exemple #3
0
	//--------------------------------------------------------------------------------------------------------------
	//生成反矩阵
	void Matrix3::SetInverse()
	{
		static Matrix3 tmp;
		Mat3Inverse( &tmp, this );
		*this = tmp;
	}