当前位置: 首页>>代码示例>>C++>>正文


C++ Vector2f::x方法代码示例

本文整理汇总了C++中eigen::Vector2f::x方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2f::x方法的具体用法?C++ Vector2f::x怎么用?C++ Vector2f::x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eigen::Vector2f的用法示例。


在下文中一共展示了Vector2f::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onValueChanged

void SliderComponent::onValueChanged()
{
	// update suffix textcache
	if(mFont)
	{
		std::stringstream ss;
		ss << std::fixed;
		ss.precision(0);
		ss << mValue;
		ss << mSuffix;
		const std::string val = ss.str();

		ss.str("");
		ss.clear();
		ss << std::fixed;
		ss.precision(0);
		ss << mMax;
		ss << mSuffix;
		const std::string max = ss.str();

		Eigen::Vector2f textSize = mFont->sizeText(max);
		mValueCache = std::shared_ptr<TextCache>(mFont->buildTextCache(val, mSize.x() - textSize.x(), (mSize.y() - textSize.y()) / 2, 0x777777FF));
		mValueCache->metrics.size[0] = textSize.x(); // fudge the width
	}

	// update knob position/size
	mKnob.setResize(0, mSize.y() * 0.7f);
	float lineLength = mSize.x() - mKnob.getSize().x() - (mValueCache ? mValueCache->metrics.size.x() + 4 : 0);
	mKnob.setPosition(((mValue + mMin) / mMax) * lineLength + mKnob.getSize().x()/2, mSize.y() / 2);
}
开发者ID:Herdinger,项目名称:EmulationStation,代码行数:30,代码来源:SliderComponent.cpp

示例2: hull

// Returns a list of points on the convex hull in counter-clockwise order.
// Note: the last point in the returned list is the same as the first one.
std::vector<int> convex_hull(std::vector<int> idxs, std::function<Eigen::Vector2f(int)> & getPoint){
    int n = idxs.size(), k = 0;
    std::vector<int> hull(2*n);

    // Sort points lexicographically
    sort(idxs.begin(), idxs.end(), [&getPoint](int a_, int b_){
        Eigen::Vector2f a = getPoint(a_);
        Eigen::Vector2f b = getPoint(b_);
        return a.x() < b.x() || (a.x() == b.x() && a.y() < b.y());
    });

    // Build lower hull
    for (int i = 0; i < n; ++i) {
        while (k >= 2 && cross(getPoint(hull[k-2]), getPoint(hull[k-1]), getPoint(idxs[i])) <= 0) k--;
        hull[k++] = idxs[i];
    }

    // Build upper hull
    for (int i = n-2, t = k+1; i >= 0; i--) {
        while (k >= t && cross(getPoint(hull[k-2]), getPoint(hull[k-1]), getPoint(idxs[i])) <= 0) k--;
        hull[k++] = idxs[i];
    }

    hull.resize(k);
    return hull;
}
开发者ID:circlingthesun,项目名称:Masters,代码行数:28,代码来源:convexhull.cpp

示例3: onCursorChanged

void TextEditComponent::onCursorChanged()
{
	if(isMultiline())
	{
		Eigen::Vector2f textSize = mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x(), mCursor); 

		if(mScrollOffset.y() + getTextAreaSize().y() < textSize.y() + mFont->getHeight()) //need to scroll down?
		{
			mScrollOffset[1] = textSize.y() - getTextAreaSize().y() + mFont->getHeight();
		}else if(mScrollOffset.y() > textSize.y()) //need to scroll up?
		{
			mScrollOffset[1] = textSize.y();
		}
	}else{
		Eigen::Vector2f cursorPos = mFont->sizeText(mText.substr(0, mCursor));

		if(mScrollOffset.x() + getTextAreaSize().x() < cursorPos.x())
		{
			mScrollOffset[0] = cursorPos.x() - getTextAreaSize().x();
		}else if(mScrollOffset.x() > cursorPos.x())
		{
			mScrollOffset[0] = cursorPos.x();
		}
	}
}
开发者ID:XD9527,项目名称:recalbox-emulationstation,代码行数:25,代码来源:TextEditComponent.cpp

示例4: drawWrappedText

//this could probably be optimized
//draws text and ensures it's never longer than xLen
void Font::drawWrappedText(std::string text, const Eigen::Vector2f& offset, float xLen, unsigned int color)
{
	float y = offset.y();

	std::string line, word, temp;
	Eigen::Vector2f textSize;
	size_t space, newline;

	while(text.length() > 0 || !line.empty()) //while there's text or we still have text to render
	{
		space = text.find(' ', 0);
		if(space == std::string::npos)
			space = text.length() - 1;


		word = text.substr(0, space + 1);

		//check if the next word contains a newline
		newline = word.find('\n', 0);
		if(newline != std::string::npos)
		{
			word = word.substr(0, newline);
			text.erase(0, newline + 1);
		}else{
			text.erase(0, space + 1);
		}

		temp = line + word;

		textSize = sizeText(temp);

		//if we're on the last word and it'll fit on the line, just add it to the line
		if((textSize.x() <= xLen && text.length() == 0) || newline != std::string::npos)
		{
			line = temp;
			word = "";
		}


		//if the next line will be too long or we're on the last of the text, render it
		if(textSize.x() > xLen || text.length() == 0 || newline != std::string::npos)
		{
			//render line now
			if(textSize.x() > 0) //make sure it's not blank
				drawText(line, Eigen::Vector2f(offset.x(), y), color);

			//increment y by height and some extra padding for the next line
			y += textSize.y() + 4;

			//move the word we skipped to the next line
			line = word;
		}else{
			//there's still space, continue building the line
			line = temp;
		}

	}
}
开发者ID:BernardWrangle,项目名称:EmulationStation,代码行数:60,代码来源:Font.cpp

示例5: pointInsideOrderedRectange

 /**
  * Checks if point is inside rectangle. Rectangle coordinate parameters are
  * ordered in this check!
  *
  * param [in]   p        point
  * param [in]   r0       lower left corner of rectange
  * param [in]   r1       upper right corner of rectange
  *
  * returns      true if point was inside or at the edge of rectangle,
  *              false otherwise
  */
 static inline bool pointInsideOrderedRectange(const Eigen::Vector2f & p, const Eigen::Vector2f & r0, const Eigen::Vector2f & r1)
 {
     if(r0.x() <= p.x() && p.x() <= r1.x() &&
         r0.y() <= p.y() && p.y() <= r1.y())
     {
         return true;
     }
     return false;
 }
开发者ID:woimalabs,项目名称:libw,代码行数:20,代码来源:Math.hpp

示例6: onCalculateButtonPress

void MainWindow::onCalculateButtonPress()
{
	arcr.setLinePoint(0, 
		ui->line0x0SpinBox->value(), ui->line0y0SpinBox->value(),
		ui->line0x1SpinBox->value(), ui->line0y1SpinBox->value(), 
		ui->line0x2SpinBox->value(), ui->line0y2SpinBox->value());
	
	arcr.setLinePoint(1,
		ui->line1x0SpinBox->value(), ui->line1y0SpinBox->value(),
		ui->line1x1SpinBox->value(), ui->line1y1SpinBox->value(),
		ui->line1x2SpinBox->value(), ui->line1y2SpinBox->value());

	arcr.computeHMatrix();

	Eigen::Vector3f img(inputImage.width(), inputImage.height(), 1.0f);
	float xmin = 0;
	float xmax = 0;
	float ymin = 0;
	float ymax = 0;
	arcr.computImageSize(0, 0, inputImage.width(), inputImage.height(), xmin, xmax, ymin, ymax);

	float aspect = (xmax - xmin) / (ymax - ymin);
	outputImage = QImage(inputImage.width(), inputImage.width() / aspect, inputImage.format());
	outputImage.fill(qRgb(0, 0, 0));

	std::cout << "Output size: " << outputImage.width() << ", " << outputImage.height() << std::endl;

	float dx = (xmax - xmin) / float(outputImage.width());
	float dy = (ymax - ymin) / float(outputImage.height());

	std::cout << std::fixed << "dx, dy: " << dx << ", " << dy << std::endl;

	for (int x = 0; x < outputImage.width(); ++x)
	{
		for (int y = 0; y < outputImage.height(); ++y)
		{
			Eigen::Vector3f px(x, y, 1);

			float tx = 0.0f;
			float ty = 0.0f;
			Eigen::Vector2f t = arcr.multiplyPointMatrixInverse(xmin + x * dx, ymin + y * dy);

			if (t.x() > -1 && t.y() > -1
				&& t.x() < inputImage.width()
				&& t.y() < inputImage.height())
			{
				QRgb rgb = bilinearInterpol(inputImage, t.x(), t.y(), dx, dy);
				outputImage.setPixel(x, y, rgb);
			}
		}
	}


	ui->outputRadioButton->setChecked(true);
	update();
}
开发者ID:diegomazala,项目名称:PerspectiveDistortionRemove,代码行数:56,代码来源:MainWindow.cpp

示例7: drawCenteredText

void Font::drawCenteredText(std::string text, float xOffset, float y, unsigned int color)
{
	Eigen::Vector2f pos = sizeText(text);
	
	pos[0] = (Renderer::getScreenWidth() - pos.x());
	pos[0] = (pos.x() / 2) + (xOffset / 2);
	pos[1] = y;

	drawText(text, pos, color);
}
开发者ID:BernardWrangle,项目名称:EmulationStation,代码行数:10,代码来源:Font.cpp

示例8: GetHeight

double Terrain::GetHeight(Eigen::Vector2f xy) const{
	
	Cube* temp_cube;
	Cylinder* temp_cylinder;

	double x = xy.x();
	double z = xy.y();
	//check if x y lands on a surface object
	for(int i = 0; i < m_surface_objects.size(); i++){
		
		switch (m_surface_objects[i]->m_type)
		{
		case TypeCube:
			temp_cube = dynamic_cast<Cube*>(m_surface_objects[i]);
			if(x < temp_cube->m_Center[0] + temp_cube->m_Size[0]*0.5
				&& x > temp_cube->m_Center[0] - temp_cube->m_Size[0]*0.5
				&& z < temp_cube->m_Center[2] + temp_cube->m_Size[2]*0.5
				&& z > temp_cube->m_Center[2] - temp_cube->m_Size[2]*0.5)
				return temp_cube->m_Size[1];
			break;
		case TypeCylinder:
			temp_cylinder = dynamic_cast<Cylinder*>(m_surface_objects[i]);
			if(x < temp_cylinder->m_Center[0] + temp_cylinder->m_Size[0]*0.5
				&&x > temp_cylinder->m_Center[0] - temp_cylinder->m_Size[0]*0.5
				&&z < temp_cylinder->m_Center[2] + temp_cylinder->m_Size[2]*0.5
				&&z > temp_cylinder->m_Center[0] - temp_cylinder->m_Size[2]*0.5)
				return sqrt(0.25*temp_cylinder->m_Size[1]*temp_cylinder->m_Size[1] - (x - temp_cylinder->m_Center[0])*(x - temp_cylinder->m_Center[0]));
			break;
		default:
			break;
		}
		
	
	}


	int idx, idz;
	idx = (xy.x() + 0.5*m_size_x)/m_dx;
	idz = (xy.y() + 0.5*m_size_z)/m_dz;

	//interpolation
	double upleft, upright, downleft, downright;
	downleft = m_height_data[idx*(m_res_z+1) + idz];
	downright = m_height_data[(idx+1)*(m_res_z+1) + idz];
	upleft = m_height_data[idx*(m_res_z+1) + idz+1];
	upright = m_height_data[(idx+1)*(m_res_z+1) + idz+1];

	double alpha, beta;
	alpha = 1 - (xy.x() + 0.5*m_size_x - idx*m_dx)/m_dx;
	beta = 1 - (xy.y() + 0.5*m_size_z - idz*m_dz)/m_dz;

	return alpha*beta*downleft + (1-alpha)*beta*downright + (1-beta)*alpha*upleft + (1-beta)*(1-alpha)*upright;
}
开发者ID:masakinakada,项目名称:Snake2,代码行数:53,代码来源:Terrain.cpp

示例9: init

bool CreditScene::init() {
  Graphics::getInstance()->fadeIn(0.6f);
  _isInit = true;

  auto playerInput = Factory::get()->loadEntityFromFile("playerInput");
  playerInput->init();
  Scene::setPlayerInput(playerInput);

 
  _credits = Factory::get()->loadEntityFromFile("credits");
  _credits->init();
  auto PosCmp = _credits->GET_CMP(PositionComponent);
  PosCmp->setPosition(Graphics::getInstance()->getScreenSize().cast<float>() * 0.5);
  auto SpCmp = _credits->GET_CMP(SpriteCmp);
  // 1.5 1.5 looks good
  SpCmp->rescale(2.0f, 2.0f);


  Eigen::Vector2f pos = Graphics::getInstance()->getScreenSize().cast<float>() * 0.75;
  pos.x() =  Graphics::getInstance()->getScreenSize().cast<float>().x() * 0.88;

  Entity* returnButton = Factory::get()->loadEntityFromFile("buttonBack");
  returnButton->init();
  std::function<void()> optionFunc = [this](){ free(); Director::get()->pushScene(new MenuScene()); };
  returnButton->GET_CMP(ButtonCmp)->setCallback(optionFunc);
  PositionComponent* posCmp = returnButton->GET_CMP(PositionComponent);
  pos.y() += 200.0f;
  posCmp->setPosition(pos);

  _buttons.push_back(returnButton);
  _cursor = _buttons.begin();
  _brighter();

  return _isInit;
}
开发者ID:sangdaekim,项目名称:greetings,代码行数:35,代码来源:creditsScene.cpp

示例10:

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

示例11: fitTo

void NinePatchComponent::fitTo(Eigen::Vector2f size, Eigen::Vector3f position, Eigen::Vector2f padding)
{
	size += padding;
	position[0] -= padding.x() / 2;
	position[1] -= padding.y() / 2;

	setSize(size + Eigen::Vector2f(getCornerSize().x() * 2, getCornerSize().y() * 2));
	setPosition(-getCornerSize().x() + position.x(), -getCornerSize().y() + position.y());
}
开发者ID:310weber,项目名称:EmulationStation,代码行数:9,代码来源:NinePatchComponent.cpp

示例12:

/**
 * Convert from image plane to pixel coordinates
 * @param camera_coordinate The 2D coordinate in camera image plane
 * @return image_coordinate The 2D coordinate in the image space
 */
Eigen::Vector2i Camera::image_plane_to_pixel( const Eigen::Vector2f & camera_coordinate ) const {
    using namespace Eigen;

    Vector3f cam_h { camera_coordinate.x(), camera_coordinate.y(), 1.0f };
    Vector3f image_h = m_k * cam_h;
    Eigen::Vector2i image_coordinate;
    image_coordinate.x( ) = std::round( image_h.x() );
    image_coordinate.y( ) = std::round( image_h.y() );
    return image_coordinate;
}
开发者ID:Scoobadood,项目名称:tsdf,代码行数:15,代码来源:Camera.cpp

示例13: applyTheme

void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties)
{
	using namespace ThemeFlags;

	const ThemeData::ThemeElement* elem = theme->getElement(view, element, "video");
	if(!elem)
	{
		return;
	}

	Eigen::Vector2f scale = getParent() ? getParent()->getSize() : Eigen::Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());

	if ((properties & POSITION) && elem->has("pos"))
	{
		Eigen::Vector2f denormalized = elem->get<Eigen::Vector2f>("pos").cwiseProduct(scale);
		setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0));
		mStaticImage.setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0));
	}

	if(properties & ThemeFlags::SIZE)
	{
		if(elem->has("size"))
			setResize(elem->get<Eigen::Vector2f>("size").cwiseProduct(scale));
		else if(elem->has("maxSize"))
			setMaxSize(elem->get<Eigen::Vector2f>("maxSize").cwiseProduct(scale));
	}

	// position + size also implies origin
	if (((properties & ORIGIN) || ((properties & POSITION) && (properties & ThemeFlags::SIZE))) && elem->has("origin"))
		setOrigin(elem->get<Eigen::Vector2f>("origin"));

	if(elem->has("default"))
		mConfig.defaultVideoPath = elem->get<std::string>("default");

	if((properties & ThemeFlags::DELAY) && elem->has("delay"))
		mConfig.startDelay = (unsigned)(elem->get<float>("delay") * 1000.0f);

	if (elem->has("showSnapshotNoVideo"))
		mConfig.showSnapshotNoVideo = elem->get<bool>("showSnapshotNoVideo");

	if (elem->has("showSnapshotDelay"))
		mConfig.showSnapshotDelay = elem->get<bool>("showSnapshotDelay");
}
开发者ID:HerbFargus,项目名称:EmulationStation,代码行数:43,代码来源:VideoComponent.cpp

示例14: onTextChanged

void TextComponent::onTextChanged()
{
	calculateExtent();

	if(!mFont || mText.empty())
	{
		mTextCache.reset();
		return;
	}

	std::string text = mUppercase ? strToUpper(mText) : mText;

	std::shared_ptr<Font> f = mFont;
	const bool isMultiline = (mSize.y() == 0 || mSize.y() > f->getHeight()*1.2f);

	bool addAbbrev = false;
	if(!isMultiline)
	{
		size_t newline = text.find('\n');
		text = text.substr(0, newline); // single line of text - stop at the first newline since it'll mess everything up
		addAbbrev = newline != std::string::npos;
	}

	Eigen::Vector2f size = f->sizeText(text);
	if(!isMultiline && mSize.x() && text.size() && (size.x() > mSize.x() || addAbbrev))
	{
		// abbreviate text
		const std::string abbrev = "...";
		Eigen::Vector2f abbrevSize = f->sizeText(abbrev);

		while(text.size() && size.x() + abbrevSize.x() > mSize.x())
		{
			size_t newSize = Font::getPrevCursor(text, text.size());
			text.erase(newSize, text.size() - newSize);
			size = f->sizeText(text);
		}

		text.append(abbrev);

		mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(text, Eigen::Vector2f(0, 0), (mColor >> 8 << 8) | mOpacity, mSize.x(), mAlignment, mLineSpacing));
	}else{
开发者ID:310weber,项目名称:EmulationStation,代码行数:41,代码来源:TextComponent.cpp

示例15: draw

  void draw(MapWriterInterface *interface)
  {
    if (!initialized_) return;

    hector_worldmodel_msgs::GetObjectModel data;
    if (!service_client_.call(data)) {
      ROS_ERROR_NAMED(name_, "Cannot draw victims, service %s failed", service_client_.getService().c_str());
      return;
    }

    std::string team_name;
    std::string mission_name;
    nh_.getParamCached("/team", team_name);
    nh_.getParamCached("/mission", mission_name);

    boost::posix_time::ptime now = ros::Time::now().toBoost();
    boost::gregorian::date now_date(now.date());
    boost::posix_time::time_duration now_time(now.time_of_day().hours(), now.time_of_day().minutes(), now.time_of_day().seconds(), 0);

    std::ofstream description_file((interface->getBasePathAndFileName() + "_qr.csv").c_str());
    if (description_file.is_open()) {
      if (!team_name.empty()) description_file << team_name << std::endl;
      description_file << now_date << "; " << now_time << std::endl;
      if (!mission_name.empty()) description_file << mission_name << std::endl;
      description_file << std::endl;
    }

    int counter = 0;
    for(hector_worldmodel_msgs::ObjectModel::_objects_type::const_iterator it = data.response.model.objects.begin(); it != data.response.model.objects.end(); ++it) {
      const hector_worldmodel_msgs::Object& object = *it;
      if (!class_id_.empty() && object.info.class_id != class_id_) continue;
      if (!draw_all_objects_ && object.state.state != hector_worldmodel_msgs::ObjectState::CONFIRMED) continue;
      if (object.state.state == hector_worldmodel_msgs::ObjectState::DISCARDED) continue;

      Eigen::Vector2f coords;
      coords.x() = object.pose.pose.position.x;
      coords.y() = object.pose.pose.position.y;
      interface->drawObjectOfInterest(coords, boost::lexical_cast<std::string>(++counter), MapWriterInterface::Color(10,10,240));

      if (description_file.is_open()) {
        boost::posix_time::time_duration time_of_day(object.header.stamp.toBoost().time_of_day());
        boost::posix_time::time_duration time(time_of_day.hours(), time_of_day.minutes(), time_of_day.seconds(), 0);
        description_file << counter << ";" << time << ";" << object.info.object_id << ";" << object.pose.pose.position.x << ";" << object.pose.pose.position.y << ";" << object.pose.pose.position.z << std::endl;
      }
    }

    description_file.close();
  }
开发者ID:deriyuval,项目名称:gazeboFilm,代码行数:48,代码来源:worldmodel_geotiff_plugins.cpp


注:本文中的eigen::Vector2f::x方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。