本文整理汇总了C++中Matrix2f::colPivHouseholderQr方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix2f::colPivHouseholderQr方法的具体用法?C++ Matrix2f::colPivHouseholderQr怎么用?C++ Matrix2f::colPivHouseholderQr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix2f
的用法示例。
在下文中一共展示了Matrix2f::colPivHouseholderQr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjustPosition
ColorWheel::Region ColorWheel::adjustPosition(const Vector2i &p, Region consideredRegions) {
float x = p.x() - mPos.x(),
y = p.y() - mPos.y(),
w = mSize.x(),
h = mSize.y();
float cx = w*0.5f;
float cy = h*0.5f;
float r1 = (w < h ? w : h) * 0.5f - 5.0f;
float r0 = r1 * .75f;
x -= cx;
y -= cy;
float mr = std::sqrt(x*x + y*y);
if ((consideredRegions & OuterCircle) &&
((mr >= r0 && mr <= r1) || (consideredRegions == OuterCircle))) {
if (!(consideredRegions & OuterCircle))
return None;
mHue = std::atan(y / x);
if (x < 0)
mHue += NVG_PI;
mHue /= 2*NVG_PI;
if (mCallback)
mCallback(color());
return OuterCircle;
}
float r = r0 - 6;
float ax = std::cos( 120.0f/180.0f*NVG_PI) * r;
float ay = std::sin( 120.0f/180.0f*NVG_PI) * r;
float bx = std::cos(-120.0f/180.0f*NVG_PI) * r;
float by = std::sin(-120.0f/180.0f*NVG_PI) * r;
typedef Eigen::Matrix<float,2,2> Matrix2f;
Eigen::Matrix<float, 2, 3> triangle;
triangle << ax,bx,r,
ay,by,0;
triangle = Eigen::Rotation2D<float>(mHue * 2 * NVG_PI).matrix() * triangle;
Matrix2f T;
T << triangle(0,0) - triangle(0,2), triangle(0,1) - triangle(0,2),
triangle(1,0) - triangle(1,2), triangle(1,1) - triangle(1,2);
Vector2f pos { x - triangle(0,2), y - triangle(1,2) };
Vector2f bary = T.colPivHouseholderQr().solve(pos);
float l0 = bary[0], l1 = bary[1], l2 = 1 - l0 - l1;
bool triangleTest = l0 >= 0 && l0 <= 1.f && l1 >= 0.f && l1 <= 1.f &&
l2 >= 0.f && l2 <= 1.f;
if ((consideredRegions & InnerTriangle) &&
(triangleTest || consideredRegions == InnerTriangle)) {
if (!(consideredRegions & InnerTriangle))
return None;
l0 = std::min(std::max(0.f, l0), 1.f);
l1 = std::min(std::max(0.f, l1), 1.f);
l2 = std::min(std::max(0.f, l2), 1.f);
float sum = l0 + l1 + l2;
l0 /= sum;
l1 /= sum;
mWhite = l0;
mBlack = l1;
if (mCallback)
mCallback(color());
return InnerTriangle;
}
return None;
}