本文整理汇总了C++中eigen::Vector2i类的典型用法代码示例。如果您正苦于以下问题:C++ Vector2i类的具体用法?C++ Vector2i怎么用?C++ Vector2i使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vector2i类的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: 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;
}
示例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();
}
示例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: 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;}}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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:
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);
}
示例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;
}
示例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;
}
}
}
示例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: 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;
}