本文整理汇总了C++中Matrix3x3函数的典型用法代码示例。如果您正苦于以下问题:C++ Matrix3x3函数的具体用法?C++ Matrix3x3怎么用?C++ Matrix3x3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix3x3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tred3
/**
* \brief Tridiagonalizes a 3x3 matrix using a single
* Householder transformation and returns the result.
*
* Based on "Geometric Tools" by David Eberly.
*/
static inline void tred3(Matrix3x3 &m, Float *diag, Float *subd) {
Float m00 = m(0, 0), m01 = m(0, 1), m02 = m(0, 2),
m11 = m(1, 1), m12 = m(1, 2), m22 = m(2, 2);
diag[0] = m00;
subd[2] = 0;
if (std::abs(m02) > std::numeric_limits<Float>::epsilon()) {
Float length = std::sqrt(m01*m01 + m02*m02),
invLength = 1 / length;
m01 *= invLength;
m02 *= invLength;
Float q = 2*m01*m12 + m02*(m22 - m11);
diag[1] = m11 + m02*q;
diag[2] = m22 - m02*q;
subd[0] = length;
subd[1] = m12 - m01*q;
m = Matrix3x3(
1, 0, 0,
0, m01, m02,
0, m02, -m01);
} else {
/* The matrix is already tridiagonal,
return an identity transformation matrix */
diag[1] = m11;
diag[2] = m22;
subd[0] = m01;
subd[1] = m12;
m = Matrix3x3(
1, 0, 0,
0, 1, 0,
0, 0, 1);
}
}
示例2: Matrix3x3
Matrix3x3 Matrix3x3::rotation(const Vector3& axis, float angleRadians) {
float angle = -angleRadians;
return Matrix3x3(
(axis.x * axis.x) * (1 - cos(angle)) + cos(angle) , axis.x * axis.y * (1 - cos(angle)) + axis.z * sin(angle), (axis.x * axis.z) * (1 - cos(angle)) - axis.y * sin(angle),
(axis.x * axis.y) * (1 - cos(angle)) - axis.z * sin(angle), axis.y * axis.y * (1 - cos(angle)) + cos(angle) , (axis.y * axis.z) * (1 - cos(angle)) + axis.x * sin(angle),
(axis.x * axis.z) * (1 - cos(angle)) + axis.y * sin(angle), axis.y * axis.z * (1 - cos(angle)) - axis.x * sin(angle), (axis.z * axis.z) * (1 - cos(angle)) + cos(angle));
}
示例3: Vector3
Matrix3x3 Quaternion::rotationMatrix3x3() const
{
Vector3 col1 = Vector3(1.0f - 2.0f * (y * y + z * z), 2.0f * (x * y + w * z), 2.0f * (x * z - w * y));
Vector3 col2 = Vector3(2.0f * (x * y - w * z), 1.0f - 2.0f * (x * x + z * z), 2.0f * (y * z + w * x));
Vector3 col3 = Vector3(2.0f * (x * z + w * y), 2.0f * (y * z - w * x), 1.0f - 2.0f * (x * x + y * y));
return Matrix3x3(col1, col2, col3);
}
示例4: Matrix3x3
Matrix3x3 Matrix3x3::CompMax(const Matrix3x3& m1,
const Matrix3x3& m2)
{
return Matrix3x3(Vector3::CompMax(m1[0], m2[0]),
Vector3::CompMax(m1[1], m2[1]),
Vector3::CompMax(m1[2], m2[2]));
}
示例5: Matrix3x3
// Return the transpose matrix
inline Matrix3x3 Matrix3x3::getTranspose() const {
// Return the transpose matrix
return Matrix3x3(mRows[0][0], mRows[1][0], mRows[2][0],
mRows[0][1], mRows[1][1], mRows[2][1],
mRows[0][2], mRows[1][2], mRows[2][2]);
}
示例6: get_unistate_mat3
Matrix3x3 get_unistate_mat3(const char *name)
{
int sidx = get_unistate_index(name);
if(sidx == -1) {
return Matrix3x3();
}
return get_unistate_mat3(sidx);
}
示例7: Matrix3x3
Matrix3x3 Matrix3x3::operator+( const Matrix3x3& rhs ) const
{
return Matrix3x3(
_00+rhs._00, _01+rhs._01, _02+rhs._02,
_10+rhs._10, _11+rhs._11, _12+rhs._12,
_20+rhs._20, _21+rhs._21, _22+rhs._22
);
}
示例8: matScale
Matrix3x3
matScale(double x,
double y)
{
return Matrix3x3(x, 0., 0.,
0., y, 0.,
0., 0., 1.);
}
示例9: matTranslation
Matrix3x3
matTranslation(double x,
double y)
{
return Matrix3x3(1., 0., x,
0., 1., y,
0., 0., 1.);
}
示例10: matRotation
Matrix3x3
matRotation(double rads)
{
double c = std::cos(rads);
double s = std::sin(rads);
return Matrix3x3(c, s, 0, -s, c, 0, 0, 0, 1);
}
示例11: matSkewXY
Matrix3x3
matSkewXY(double skewX,
double skewY,
bool skewOrderYX)
{
return Matrix3x3(skewOrderYX ? 1. : (1. + skewX * skewY), skewX, 0.,
skewY, skewOrderYX ? (1. + skewX * skewY) : 1, 0.,
0., 0., 1.);
}
示例12: set_view_matrix
void TargetCamera::set_camera(long time)
{
set_view_matrix(get_matrix());
set_unistate("st_view_matrix3",Matrix3x3(get_matrix()));
//DEBUG
Matrix4x4 view = get_matrix();
glMatrixMode(GL_MODELVIEW);
glLoadTransposeMatrixf(view[0]);
}
示例13: Matrix3x3
Matrix3x3 Matrix3x3::Transpose() const
{
float data[9];
int cnt = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
data[cnt++] = data_[j][i];
}
}
return Matrix3x3(data);
}
示例14: matMul
Matrix3x3
matMul(const Matrix3x3 & m1,
const Matrix3x3 & m2)
{
return Matrix3x3(m1.a * m2.a + m1.b * m2.d + m1.c * m2.g,
m1.a * m2.b + m1.b * m2.e + m1.c * m2.h,
m1.a * m2.c + m1.b * m2.f + m1.c * m2.i,
m1.d * m2.a + m1.e * m2.d + m1.f * m2.g,
m1.d * m2.b + m1.e * m2.e + m1.f * m2.h,
m1.d * m2.c + m1.e * m2.f + m1.f * m2.i,
m1.g * m2.a + m1.h * m2.d + m1.i * m2.g,
m1.g * m2.b + m1.h * m2.e + m1.i * m2.h,
m1.g * m2.c + m1.h * m2.f + m1.i * m2.i);
}
示例15: tmp
Matrix3x3 Matrix3x3::getTranspose()
{
std::vector<float> tmp(9);
for (int i = 0; i < 3; i++)
{
tmp[3 * i] = elements[i];
tmp[3 * i + 1] = elements[i + 3];
tmp[3 * i + 2] = elements[i + 6];
}
return Matrix3x3(tmp);
}