本文整理汇总了C++中eigen::Vector2i::y方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2i::y方法的具体用法?C++ Vector2i::y怎么用?C++ Vector2i::y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Vector2i
的用法示例。
在下文中一共展示了Vector2i::y方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Font::FontTexture::findEmpty(const Eigen::Vector2i& size, Eigen::Vector2i& cursor_out)
{
if(size.x() >= textureSize.x() || size.y() >= textureSize.y())
return false;
if(writePos.x() + size.x() >= textureSize.x() &&
writePos.y() + rowHeight + size.y() + 1 < textureSize.y())
{
// row full, but it should fit on the next row
// move cursor to next row
writePos << 0, writePos.y() + rowHeight + 1; // leave 1px of space between glyphs
rowHeight = 0;
}
if(writePos.x() + size.x() >= textureSize.x() ||
writePos.y() + size.y() >= textureSize.y())
{
// nope, still won't fit
return false;
}
cursor_out = writePos;
writePos[0] += size.x() + 1; // leave 1px of space between glyphs
if(size.y() > rowHeight)
rowHeight = size.y();
return true;
}
示例2: mouseButtonEvent
bool GraphNode::mouseButtonEvent(const Eigen::Vector2i &p, int button, bool down, int modifiers)
{
spdlog::get("qde")->debug(
"GraphNode '{}': Received mouse button event at ({},{}): {}, {}",
mTitle, p.x(), p.y(), button, down
);
Window::mouseButtonEvent(p, button, down, modifiers);
if (button == GLFW_MOUSE_BUTTON_1 && mEnabled && down) {
Graph *parentGraph = dynamic_cast<Graph *>(mParent);
parentGraph->nodeSelectedEvent(this);
return true;
}
else if (button == GLFW_MOUSE_BUTTON_2 && mEnabled && down) {
int offsetX = p.x() - mPos.x();
int offsetY = p.y() - mPos.y();
Eigen::Vector2i position(offsetX, offsetY);
mPopup->setAnchorPos(position);
mPopup->setVisible(!mPopup->visible());
return true;
}
return false;
}
示例3: getGlyph
Font::Glyph* Font::getGlyph(UnicodeChar id)
{
// is it already loaded?
auto it = mGlyphMap.find(id);
if(it != mGlyphMap.end())
return &it->second;
// nope, need to make a glyph
FT_Face face = getFaceForChar(id);
if(!face)
{
LOG(LogError) << "Could not find appropriate font face for character " << id << " for font " << mPath;
return NULL;
}
FT_GlyphSlot g = face->glyph;
if(FT_Load_Char(face, id, FT_LOAD_RENDER))
{
LOG(LogError) << "Could not find glyph for character " << id << " for font " << mPath << ", size " << mSize << "!";
return NULL;
}
Eigen::Vector2i glyphSize(g->bitmap.width, g->bitmap.rows);
FontTexture* tex = NULL;
Eigen::Vector2i cursor;
getTextureForNewGlyph(glyphSize, tex, cursor);
// getTextureForNewGlyph can fail if the glyph is bigger than the max texture size (absurdly large font size)
if(tex == NULL)
{
LOG(LogError) << "Could not create glyph for character " << id << " for font " << mPath << ", size " << mSize << " (no suitable texture found)!";
return NULL;
}
// create glyph
Glyph& glyph = mGlyphMap[id];
glyph.texture = tex;
glyph.texPos << cursor.x() / (float)tex->textureSize.x(), cursor.y() / (float)tex->textureSize.y();
glyph.texSize << glyphSize.x() / (float)tex->textureSize.x(), glyphSize.y() / (float)tex->textureSize.y();
glyph.advance << (float)g->metrics.horiAdvance / 64.0f, (float)g->metrics.vertAdvance / 64.0f;
glyph.bearing << (float)g->metrics.horiBearingX / 64.0f, (float)g->metrics.horiBearingY / 64.0f;
// upload glyph bitmap to texture
glBindTexture(GL_TEXTURE_2D, tex->textureId);
glTexSubImage2D(GL_TEXTURE_2D, 0, cursor.x(), cursor.y(), glyphSize.x(), glyphSize.y(), GL_ALPHA, GL_UNSIGNED_BYTE, g->bitmap.buffer);
glBindTexture(GL_TEXTURE_2D, 0);
// update max glyph height
if(glyphSize.y() > mMaxGlyphHeight)
mMaxGlyphHeight = glyphSize.y();
// done
return &glyph;
}
示例4: checkValidTile
bool PathCmp::checkValidTile (Eigen::Vector2i idx_) {
if (0 <=idx_.x() && idx_.x() < _level->getXSize()
&& 0 <= idx_.y() && idx_.y() < _level->getYSize()) {
if (_level->getTile(idx_.x(), idx_.y()))
return false;
return true;
}
return false;
}
示例5: setBuoy
bool DepthObstacleGrid::setBuoy( double x, double y, BuoyColor color, double confidence, bool no_neigbors){
Eigen::Vector2i ID = getCellID(x,y);
//std::cout << "idX: " << idX << " span: " << span.x() << " resolution: " << resolution << " x: " << x << " pos: " << position.x() << std::endl;
if(ID.x() < 0)
return false;
bool ignore = false;
if(no_neigbors){
for(signed int i = -1; i <= 1; i++){
for(signed int j = -1; j <= 1; j++){
if(isValid( ID.x() + i, ID.y() + j)){
GridElement neighbor = get(ID.x() + i, ID.y() + j);
if(neighbor.buoy_confidence > 0.0){
ignore = true;
}
}
}
}
}else{
ignore = false;
}
if(ignore){
return false;
}
GridElement &elem = get(ID.x(), ID.y());
if(confidence > 0.0){
elem.buoy_confidence = elem.buoy_confidence + confidence - (elem.buoy_confidence * confidence);
if(color == WHITE){
elem.white_buoy_confidence = elem.white_buoy_confidence + confidence - (elem.white_buoy_confidence * confidence);
}
else if(color == ORANGE){
elem.orange_buoy_confidence = elem.orange_buoy_confidence + confidence - (elem.orange_buoy_confidence * confidence);
}
else if(color == YELLOW){
elem.yellow_buoy_confidence = elem.yellow_buoy_confidence + confidence - (elem.yellow_buoy_confidence * confidence);
}
}
return true;
}
示例6: moveCursor
bool ComponentGrid::moveCursor(Eigen::Vector2i dir)
{
assert(dir.x() || dir.y());
const Eigen::Vector2i origCursor = mCursor;
GridEntry* currentCursorEntry = getCellAt(mCursor);
Eigen::Vector2i searchAxis(dir.x() == 0, dir.y() == 0);
while(mCursor.x() >= 0 && mCursor.y() >= 0 && mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y())
{
mCursor = mCursor + dir;
Eigen::Vector2i curDirPos = mCursor;
GridEntry* cursorEntry;
//spread out on search axis+
while(mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y()
&& mCursor.x() >= 0 && mCursor.y() >= 0)
{
cursorEntry = getCellAt(mCursor);
if(cursorEntry && cursorEntry->canFocus && cursorEntry != currentCursorEntry)
{
onCursorMoved(origCursor, mCursor);
return true;
}
mCursor += searchAxis;
}
//now again on search axis-
mCursor = curDirPos;
while(mCursor.x() >= 0 && mCursor.y() >= 0
&& mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y())
{
cursorEntry = getCellAt(mCursor);
if(cursorEntry && cursorEntry->canFocus && cursorEntry != currentCursorEntry)
{
onCursorMoved(origCursor, mCursor);
return true;
}
mCursor -= searchAxis;
}
mCursor = curDirPos;
}
//failed to find another focusable element in this direction
mCursor = origCursor;
return false;
}
示例7:
Eigen::Matrix3f TextureWarpShader::adjustHomography(const Eigen::Vector2i &imageSize, const Eigen::Matrix3fr &H)
{
Eigen::Matrix3f finalH;
Eigen::Matrix3fr normHR = Eigen::Matrix3fr::Identity();
normHR(0, 0) = (float)(imageSize.x() - 1);
normHR(1, 1) = (float)(imageSize.y() - 1);
Eigen::Matrix3fr normHL = Eigen::Matrix3fr::Identity();
normHL(0, 0) = 1.0f / (imageSize.x() - 1);
normHL(1, 1) = 1.0f / (imageSize.y() - 1);
return (normHL * H * normHR);
}
示例8: calcCostG
int PathCmp::calcCostG (PathNode* node_, PathNode* parentNode_) {
Eigen::Vector2i nodeIdx = node_->getIndex();
Eigen::Vector2i parentIdx;
if (parentNode_)
parentIdx = parentNode_->getIndex();
else
parentIdx = _srcIdx;
int costToAdd = 10;
if (abs(nodeIdx.x() - parentIdx.x()) == 1
&& abs(nodeIdx.y() - parentIdx.y()) == 1)
costToAdd = 14;
return costToAdd;
}
示例9: GuiComponent
ComponentGrid::ComponentGrid(Window* window, const Eigen::Vector2i& gridDimensions) : GuiComponent(window),
mGridSize(gridDimensions), mCursor(0, 0)
{
assert(gridDimensions.x() > 0 && gridDimensions.y() > 0);
mCells.reserve(gridDimensions.x() * gridDimensions.y());
mColWidths = new float[gridDimensions.x()];
mRowHeights = new float[gridDimensions.y()];
for(int x = 0; x < gridDimensions.x(); x++)
mColWidths[x] = 0;
for(int y = 0; y < gridDimensions.y(); y++)
mRowHeights[y] = 0;
}
示例10: getBuoy
BuoyColor DepthObstacleGrid::getBuoy(double x, double y){
Eigen::Vector2i ID = getCellID(x,y);
if(ID.x() < 0)
return NO_BUOY;
GridElement elem = get(ID.x(), ID.y());
if(elem.orange_buoy_confidence > elem.white_buoy_confidence){
if(elem.orange_buoy_confidence > 0.0){
return ORANGE;
}
}
else{
if(elem.white_buoy_confidence > 0.0){
return WHITE;
}
}
if(elem.buoy_confidence > 0.0){
return UNKNOWN;
}
return NO_BUOY;
}
示例11: setDepth
void DepthObstacleGrid::setDepth(double x, double y, double depth, double variance){
Eigen::Vector2i ID = getCellID(x,y);
//std::cout << "idX: " << idX << " span: " << span.x() << " resolution: " << resolution << " x: " << x << " pos: " << position.x() << std::endl;
if(ID.x() < 0)
return;
GridElement &elem = get(ID.x(), ID.y());
if(variance == 0.0){
elem.pos = base::Vector2d(x,y);
}
else if( std::isinf(elem.depth_variance)){
elem.depth = depth;
elem.depth_variance = variance;
}
else{
double k = elem.depth_variance / (variance + elem.depth_variance);
elem.depth = elem.depth + ( k * (depth - elem.depth ) ) ;
elem.depth_variance = elem.depth_variance - (k * elem.depth_variance);
}
}
示例12:
Terrain::Terrain(Eigen::Vector2f a_size, Eigen::Vector2i a_res, int n_hill, TerrainType a_type){
m_type = TypeTerrain;
m_frictness = 10;
InitBase(a_size.x(), a_size.y(), a_res.x(), a_res.y(), n_hill, a_type);
InitDraw();
}
示例13: onDestroyed
void TileLogicCmp::onDestroyed (OnTileDestroyed* event_){
if (!event_->_tile)
return;
if(event_->_tile == getEntity()){
auto level = Director::getInstance()->getRunningScene()->getLevel();
auto pos = getEntity()->GET_CMP(PositionComponent)->getPosition();
Eigen::Vector2i idx = level->posToTileIndex(pos);
level->removeCell(idx.x(), idx.y());
event_->_tile = nullptr;}}
示例14: draw
void GraphNodeLink::draw(NVGcontext* ctx)
{
auto sourceSize = mSource->size().cast<float>();
Eigen::Vector2i inputPosition(
mSource->absolutePosition().x() - mParent->absolutePosition().x() + (sourceSize.x() * 0.5f),
mSource->absolutePosition().y() - mParent->absolutePosition().y() + (sourceSize.y() * 0.5f)
);
Eigen::Vector2i outputPosition(Eigen::Vector2i::Zero());
if (hasTarget()) {
// Get relative position of parent (node) of the target (sink)
Eigen::Vector2i delta = mSink->parent()->absolutePosition() - mSink->parent()->position();
delta.x() -= (sourceSize.x() * 0.5f);
delta.y() -= (sourceSize.y() * 0.5f);
outputPosition = mSink->absolutePosition() - delta;
}
else {
Eigen::Vector2i offset = mSource->absolutePosition() - mParent->absolutePosition();
Eigen::Vector2i delta = mTargetPosition - mSource->position();
outputPosition = offset + delta;
}
Eigen::Vector2i positionDiff = outputPosition - inputPosition;
NVGcontext* vg = ctx;
nvgStrokeColor(vg, nvgRGBA(131, 148, 150, 255));
nvgStrokeWidth(vg, 2.0f);
nvgBeginPath(vg);
nvgMoveTo(
vg,
inputPosition.x(),
inputPosition.y()
);
nvgQuadTo(vg,
1.2 * positionDiff.x(), positionDiff.y(),
outputPosition.x(), outputPosition.y()
);
nvgStroke(vg);
Widget::draw(ctx);
}
示例15: paintCache
void KisColorSelectorRing::paintCache()
{
QImage cache(m_cachedSize, m_cachedSize, QImage::Format_ARGB32_Premultiplied);
Eigen::Vector2i center(cache.width()/2., cache.height()/2.);
for(int x=0; x<cache.width(); x++) {
for(int y=0; y<cache.height(); y++) {
Eigen::Vector2i currentPoint((float)x, (float)y);
Eigen::Vector2i relativeVector = currentPoint-center;
qreal currentRadius = relativeVector.squaredNorm();
currentRadius=sqrt(currentRadius);
if(currentRadius < outerRadius()+1
&& currentRadius > innerRadius()-1)
{
float angle = std::atan2((float)relativeVector.y(), (float)relativeVector.x())+((float)M_PI);
angle/=2*((float)M_PI);
angle*=359.f;
if(currentRadius < outerRadius()
&& currentRadius > innerRadius()) {
cache.setPixel(x, y, m_cachedColors.at(angle));
}
else {
// draw antialiased border
qreal coef=1.;
if(currentRadius > outerRadius()) {
// outer border
coef-=currentRadius;
coef+=outerRadius();
}
else {
// inner border
coef+=currentRadius;
coef-=innerRadius();
}
coef=qBound(qreal(0.), coef, qreal(1.));
int red=qRed(m_cachedColors.at(angle));
int green=qGreen(m_cachedColors.at(angle));
int blue=qBlue(m_cachedColors.at(angle));
// the format is premultiplied, so we have to take care of that
QRgb color = qRgba(red*coef, green*coef, blue*coef, 255*coef);
cache.setPixel(x, y, color);
}
}
else {
cache.setPixel(x, y, qRgba(0,0,0,0));
}
}
}
m_pixelCache = cache;
}