本文整理汇总了C++中eigen::Vector2i类的典型用法代码示例。如果您正苦于以下问题:C++ Vector2i类的具体用法?C++ Vector2i怎么用?C++ Vector2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vector2i类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:sosterwalder,项目名称:mte7102-proj2,代码行数:27,代码来源:graphnode.cpp
示例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);
}
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:26,代码来源:depth_obstacle_grid.cpp
示例3: 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;
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:28,代码来源:depth_obstacle_grid.cpp
示例4:
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();
}
开发者ID:masakinakada,项目名称:Snake2,代码行数:8,代码来源:Terrain.cpp
示例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;
}
开发者ID:Herdinger,项目名称:EmulationStation,代码行数:58,代码来源:Font.cpp
示例6: 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;}}
开发者ID:sangdaekim,项目名称:greetings,代码行数:9,代码来源:tileLogic.cpp
示例7:
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;
}
开发者ID:Herdinger,项目名称:EmulationStation,代码行数:29,代码来源:Font.cpp
示例8: 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;
}
开发者ID:KDE,项目名称:krita,代码行数:55,代码来源:kis_color_selector_ring.cpp
示例9: 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;
}
}
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:53,代码来源:depth_obstacle_grid.cpp
示例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;
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:12,代码来源:depth_obstacle_grid.cpp
示例11:
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);
}
开发者ID:caomw,项目名称:planecalib,代码行数:12,代码来源:TextureWarpShader.cpp
示例12: 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;
}
开发者ID:jacobfk20,项目名称:EmulationStation-RPiE,代码行数:53,代码来源:ComponentGrid.cpp
示例13: gridLine
void GridLineTraversal::gridLine(Eigen::Vector2i start, Eigen::Vector2i end, GridLineTraversalLine *line) {
int i, j;
int half;
Eigen::Vector2i v;
gridLineCore(start, end, line);
if(start.x() != line->points[0].x() || start.y() != line->points[0].y()) {
half = line->numPoints / 2;
for(i = 0, j = line->numPoints - 1; i < half; i++, j--) {
v = line->points[i];
line->points[i] = line->points[j];
line->points[j] = v;
}
}
}
开发者ID:9578577,项目名称:g2o_frontend,代码行数:14,代码来源:grid_line_traversal.cpp
示例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;
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:15,代码来源:depth_obstacle_grid.cpp
示例15: 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;
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:57,代码来源:depth_obstacle_grid.cpp
示例16: initializeStatics
void DepthObstacleGrid::initializeStatics(NodeMap *map){
Environment env = map->getEnvironment();
for(std::vector<Plane>::iterator it = env.planes.begin(); it != env.planes.end(); it++){
double plane_length = Eigen::Vector2d( it->span_horizontal.x(), it->span_horizontal.y() ).norm();
Eigen::Vector2d step = Eigen::Vector2d( it->span_horizontal.x(), it->span_horizontal.y() ) / (plane_length / (0.5 * resolution) );
double step_length = step.norm();
Eigen::Vector2d lastCell(NAN, NAN);
Eigen::Vector2d pos = Eigen::Vector2d(it->position.x(), it->position.y());
//iterate through the cells
for(double i = 0.0; i < plane_length; i += step_length){
Eigen::Vector2d cell_coord = getGridCoord( pos.x(), pos.y() );
//step was not wide enough, we are still in the same cell
if(cell_coord != lastCell){
lastCell = cell_coord;
Eigen::Vector2i ID = getCellID(cell_coord.x(), cell_coord.y());
//Step was invalid, we are outside the grid
if(ID.x() == -1){
pos += step;
continue;
}
//Set the cell static
GridElement &elem = get(ID.x(), ID.y());
elem.static_obstacle = true;
}
pos += step;
}
}
}
开发者ID:auv-avalon,项目名称:uw_localization,代码行数:44,代码来源:depth_obstacle_grid.cpp
示例17: 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;
}
开发者ID:jacobfk20,项目名称:EmulationStation-RPiE,代码行数:14,代码来源:ComponentGrid.cpp
示例18: setEntry
void ComponentGrid::setEntry(const std::shared_ptr<GuiComponent>& comp, const Eigen::Vector2i& pos, bool canFocus, bool resize, const Eigen::Vector2i& size,
unsigned int border, GridFlags::UpdateType updateType)
{
assert(pos.x() >= 0 && pos.x() < mGridSize.x() && pos.y() >= 0 && pos.y() < mGridSize.y());
assert(comp != nullptr);
assert(comp->getParent() == NULL);
GridEntry entry(pos, size, comp, canFocus, resize, updateType, border);
mCells.push_back(entry);
addChild(comp.get());
if(!cursorValid() && canFocus)
{
auto origCursor = mCursor;
mCursor = pos;
onCursorMoved(origCursor, mCursor);
}
updateCellComponent(mCells.back());
updateSeparators();
}
开发者ID:jacobfk20,项目名称:EmulationStation-RPiE,代码行数:22,代码来源:ComponentGrid.cpp
示例19: pushClipRect
void pushClipRect(Eigen::Vector2i pos, Eigen::Vector2i dim)
{
Eigen::Vector4i box(pos.x(), pos.y(), dim.x(), dim.y());
if(box[2] == 0)
box[2] = Renderer::getScreenWidth() - box.x();
if(box[3] == 0)
box[3] = Renderer::getScreenHeight() - box.y();
//glScissor starts at the bottom left of the window
//so (0, 0, 1, 1) is the bottom left pixel
//everything else uses y+ = down, so flip it to be consistent
//rect.pos.y = Renderer::getScreenHeight() - rect.pos.y - rect.size.y;
box[1] = Renderer::getScreenHeight() - box.y() - box[3];
//make sure the box fits within clipStack.top(), and clip further accordingly
if(clipStack.size())
{
Eigen::Vector4i& top = clipStack.top();
if(top[0] > box[0])
box[0] = top[0];
if(top[1] > box[1])
box[1] = top[1];
if(top[0] + top[2] < box[0] + box[2])
box[2] = (top[0] + top[2]) - box[0];
if(top[1] + top[3] < box[1] + box[3])
box[3] = (top[1] + top[3]) - box[1];
}
if(box[2] < 0)
box[2] = 0;
if(box[3] < 0)
box[3] = 0;
clipStack.push(box);
glScissor(box[0], box[1], box[2], box[3]);
glEnable(GL_SCISSOR_TEST);
}
开发者ID:Cheaves,项目名称:EmulationStation,代码行数:37,代码来源:Renderer_draw_gl.cpp
示例20: 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;
}
开发者ID:sangdaekim,项目名称:greetings,代码行数:9,代码来源:pathCmp.cpp
注:本文中的eigen::Vector2i类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论