本文整理汇总了C++中base::Matrix4D::setToUnity方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4D::setToUnity方法的具体用法?C++ Matrix4D::setToUnity怎么用?C++ Matrix4D::setToUnity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::Matrix4D
的用法示例。
在下文中一共展示了Matrix4D::setToUnity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transformGeometry
void PropertyCurvatureList::transformGeometry(const Base::Matrix4D &mat)
{
// The principal direction is only a vector with unit length, so we only need to rotate it
// (no translations or scaling)
// Extract scale factors (assumes an orthogonal rotation matrix)
// Use the fact that the length of the row vectors of R are all equal to 1
// And that scaling is applied after rotating
double s[3];
s[0] = sqrt(mat[0][0] * mat[0][0] + mat[0][1] * mat[0][1] + mat[0][2] * mat[0][2]);
s[1] = sqrt(mat[1][0] * mat[1][0] + mat[1][1] * mat[1][1] + mat[1][2] * mat[1][2]);
s[2] = sqrt(mat[2][0] * mat[2][0] + mat[2][1] * mat[2][1] + mat[2][2] * mat[2][2]);
// Set up the rotation matrix: zero the translations and make the scale factors = 1
Base::Matrix4D rot;
rot.setToUnity();
for (unsigned short i = 0; i < 3; i++) {
for (unsigned short j = 0; j < 3; j++) {
rot[i][j] = mat[i][j] / s[i];
}
}
aboutToSetValue();
// Rotate the principal directions
for (int ii=0; ii<getSize(); ii++)
{
CurvatureInfo ci = operator[](ii);
ci.cMaxCurvDir = rot * ci.cMaxCurvDir;
ci.cMinCurvDir = rot * ci.cMinCurvDir;
_lValueList[ii] = ci;
}
hasSetValue();
}
示例2: Exception
Base::Matrix4D AbstractPolygonTriangulator::GetTransformToFitPlane() const
{
PlaneFit planeFit;
for (std::vector<Base::Vector3f>::const_iterator it = _points.begin(); it!=_points.end(); ++it)
planeFit.AddPoint(*it);
if (planeFit.Fit() == FLOAT_MAX)
throw Base::Exception("Plane fit failed");
Base::Vector3f bs = planeFit.GetBase();
Base::Vector3f ex = planeFit.GetDirU();
Base::Vector3f ey = planeFit.GetDirV();
Base::Vector3f ez = planeFit.GetNormal();
// build the matrix for the inverse transformation
Base::Matrix4D rInverse;
rInverse.setToUnity();
rInverse[0][0] = ex.x; rInverse[0][1] = ey.x; rInverse[0][2] = ez.x; rInverse[0][3] = bs.x;
rInverse[1][0] = ex.y; rInverse[1][1] = ey.y; rInverse[1][2] = ez.y; rInverse[1][3] = bs.y;
rInverse[2][0] = ex.z; rInverse[2][1] = ey.z; rInverse[2][2] = ez.z; rInverse[2][3] = bs.z;
return rInverse;
}
示例3: transformGeometry
void PropertyNormalList::transformGeometry(const Base::Matrix4D &mat)
{
// A normal vector is only a direction with unit length, so we only need to rotate it
// (no translations or scaling)
// Extract scale factors (assumes an orthogonal rotation matrix)
// Use the fact that the length of the row vectors of R are all equal to 1
// And that scaling is applied after rotating
double s[3];
s[0] = sqrt(mat[0][0] * mat[0][0] + mat[0][1] * mat[0][1] + mat[0][2] * mat[0][2]);
s[1] = sqrt(mat[1][0] * mat[1][0] + mat[1][1] * mat[1][1] + mat[1][2] * mat[1][2]);
s[2] = sqrt(mat[2][0] * mat[2][0] + mat[2][1] * mat[2][1] + mat[2][2] * mat[2][2]);
// Set up the rotation matrix: zero the translations and make the scale factors = 1
Base::Matrix4D rot;
rot.setToUnity();
for (unsigned short i = 0; i < 3; i++) {
for (unsigned short j = 0; j < 3; j++) {
rot[i][j] = mat[i][j] / s[i];
}
}
aboutToSetValue();
// Rotate the normal vectors
#ifdef _WIN32
Concurrency::parallel_for_each(_lValueList.begin(), _lValueList.end(), [rot](Base::Vector3f& value) {
value = rot * value;
});
#else
QtConcurrent::blockingMap(_lValueList, [rot](Base::Vector3f& value) {
rot.multVec(value, value);
});
#endif
hasSetValue();
}