本文整理汇总了C++中eigen::Vector2i::x方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2i::x方法的具体用法?C++ Vector2i::x怎么用?C++ Vector2i::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Vector2i
的用法示例。
在下文中一共展示了Vector2i::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3:
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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8:
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);
}
示例9: 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;
}
示例10: getDepth
double DepthObstacleGrid::getDepth( double x, double y){
Eigen::Vector2i ID = getCellID(x,y);
if(ID.x() < 0)
return NAN;
GridElement elem = get(ID.x(), ID.y());
return elem.depth;
}
示例11: setObstacle
void DepthObstacleGrid::setObstacle(double x, double y, bool obstacle, double confidence){
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( (!elem.obstacle) && obstacle){
elem.init_confidences(min_depth, max_depth, depth_resolution);
elem.obstacle = true;
elem.obstacle_confidence = confidence + 0.5 - (confidence * 0.5);
setObstacleDepthConfidence(elem.obstacle_depth_confidence, min_depth, max_depth, confidence, obstacle);
elem.obstacle_count++;
}
else if(confidence > 0.0){
setObstacleDepthConfidence(elem.obstacle_depth_confidence, min_depth, max_depth, confidence, obstacle);
if(obstacle == false && elem.obstacle && confidence > 0){ //we do not see an old feature --> reduce feature confidence
//feature.obstacle_confidence = ((1.0 - confidence) + f.obstacle_confidence) * 0.5;
//Confidence, that the cell is empty
double confidence_empty = (1.0 - elem.obstacle_confidence) + confidence - ((1.0 - elem.obstacle_confidence) * confidence);
//Obstacle ceonfidence is reverse of empty-confidence
elem.obstacle_confidence = 1.0 - confidence_empty;
}else if(obstacle == elem.obstacle && obstacle && confidence > 0){ // We recognized the feature before, update the confidence
//feature.obstacle_confidence = (confidence + f.obstacle_confidence) * 0.5 ;
elem.obstacle_confidence = elem.obstacle_confidence + confidence - (elem.obstacle_confidence * confidence);
elem.obstacle_count++;
}
else if(obstacle && elem.obstacle == false && confidence > 0){ //we recognize this feature for the first time
elem.obstacle = true;
//The confidence before was 0.5, because we did not know, if the cell is empty or occupied
elem.obstacle_confidence = confidence + 0.5 - (confidence * 0.5);
elem.obstacle_count++;
}
if(elem.obstacle_confidence <= obstacle_confidence_threshold && !elem.is_obstacle(obstacle_confidence_threshold) && elem.obstacle_count < obstacle_count_threshold){ // We have no confidence in this feature
elem.obstacle = false;
elem.obstacle_count = 0;
}
}
}
示例12: 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;
}
示例13: 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;
}
示例14: getObstacle
bool DepthObstacleGrid::getObstacle( double x, double y){
Eigen::Vector2i ID = getCellID(x,y);
if(ID.x() < 0)
return false;
GridElement elem = get(ID.x(), ID.y());
if(elem.obstacle_confidence <= 0.0)
return false;
else
return elem.obstacle;
}
示例15:
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();
}