• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ vector2d类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中vector2d的典型用法代码示例。如果您正苦于以下问题:C++ vector2d类的具体用法?C++ vector2d怎么用?C++ vector2d使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1:

buw::vector2d OpenInfraPlatform::Infrastructure::VerticalAlignmentElement2DArc::Rotate(const double angle, const vector2d& v) const
{
	return buw::vector2d(
		std::cos(angle) * v.x() - std::sin(angle) * v.y(),
		std::sin(angle) * v.x() + std::cos(angle) * v.y()
	);
}
开发者ID:bigdoods,项目名称:OpenInfraPlatform,代码行数:7,代码来源:VerticalAlignmentElement2DArc.cpp


示例2: nextground

	float footholdtree::nextground(bool left, vector2d pos)
	{
		//return getgroundbelow(pos);

		short nextid = -1;
		if (left && pos.x() < ground.horizontal.x())
		{
			nextid = ground.prev;
		}
		else if (!left && pos.x() > ground.horizontal.y())
		{
			nextid = ground.next;
		}

		if (nextid > 0)
		{
			ground = footholds[nextid];

			if (ground.isfloor())
			{
				return static_cast<float>(ground.vertical.x());
			}
			else
			{
				float step = static_cast<float>((ground.vertical.y() - ground.vertical.x())) / (ground.horizontal.y() - ground.horizontal.x());
				return static_cast<float>(ground.vertical.x() + (step * (pos.x() - ground.horizontal.x())));
			}
		}
		else
		{
			return getgroundbelow(pos);
		}
	}
开发者ID:thisIsTooHard,项目名称:journey_client,代码行数:33,代码来源:footholdtree.cpp


示例3:

	mesodrop::mesodrop(short o, animation* ani, int own, vector2d pos, vector2d dst, char type, bool pld)
	{
		oid = o;
		anim = ani;
		owner = own;
		pickuptype = type;
		playerdrop = pld;

		fx = static_cast<float>(pos.x());
		fy = static_cast<float>(pos.y());

		updatefht();

		dalpha = 1.0f;
		alpha = 1.0f;
		moved = 0.0f;

		if (pos == dst)
		{
			state = DST_FLOATING;
			vspeed = 0;
			hspeed = 0;
			basey = fy;
		}
		else
		{
			state = DST_DROPPED;
			vspeed = -6.0f;
			hspeed = static_cast<float>(dst.x() - pos.x()) / 16;
		}
	}
开发者ID:LankMasterFlex,项目名称:journey_client,代码行数:31,代码来源:mesodrop.cpp


示例4:

float vector2d::operator * (vector2d vec) const {
	/*!	\brief Calculates the scalar product of the object it is called on and the vector in the argument and returns the result.
	 *	\param vec vector2d to multiply with.
	 *	\return The scalar product.
	 */
	return ((_x * vec.getX()) + (_y * vec.getY()));
}
开发者ID:FlopsKa,项目名称:libvec2d,代码行数:7,代码来源:vector2d.cpp


示例5: tmp

vector2d vector2d::operator - (vector2d vec) const {
	/*!	\brief Substracts the vector from the argument from this vector and returns the result.
	 *	\param vec Vector to substract.
	 *	\return The difference.
	 */
	vector2d tmp(_x - vec.getX(), _y - vec.getY());
	return tmp;
}
开发者ID:FlopsKa,项目名称:libvec2d,代码行数:8,代码来源:vector2d.cpp


示例6: vector2d

	float footholdtree::getgroundbelow(vector2d pos)
	{
		foothold ret;
		float ycomp = 65536;
		pos = pos - vector2d(0, 5);
		for (map<short, foothold>::iterator ftit = footholds.begin(); ftit != footholds.end(); ftit++)
		{
			if (ftit->second.horizontal.contains(pos.x()))
			{
				float y;
				if (ftit->second.isfloor())
				{
					y = static_cast<float>(ftit->second.vertical.x());
				}
				else
				{
					float step = static_cast<float>((ftit->second.vertical.y() - ftit->second.vertical.x())) / (ftit->second.horizontal.y() - ftit->second.horizontal.x());
					y = static_cast<float>(ftit->second.vertical.x() + (step * (pos.x() - ftit->second.horizontal.x())));
				}

				if (ycomp > y && y > pos.y())
				{
					ret = ftit->second;
					ycomp = y;
				}
			}
		}

		ground = ret;
		return ycomp;
		

		/*int closest = lowestg;
		pos = pos - vector2d(0, 5);

		for (vector<map<short, short>>::iterator pfit = platforms.begin(); pfit != platforms.end(); ++pfit)
		{
			if (pfit->count(pos.x()))
			{
				int py = pfit->at(pos.x());

				if (py <= closest && py >= pos.y())
				{
					closest = py;
				}
			}
		}

		return static_cast<float>(closest);*/
	}
开发者ID:thisIsTooHard,项目名称:journey_client,代码行数:50,代码来源:footholdtree.cpp


示例7:

bool vector2d::operator!=(const vector2d& other)
{
	int i = 0;

	if (afData[0] == other.x())
	{
		i++;
	}
	if (afData[1] == other.y())
	{
		i++;
	}
	return i != 2;
}
开发者ID:JosephRadu,项目名称:zombie_game_2,代码行数:14,代码来源:vector2d.cpp


示例8: draw

	void TextWrapperGL::draw(vector2d<int32_t> pos) const
	{
		const FontsFT* fonts = LocatorGL::getfonts();
		if (false)
		{
			const FT_Face* fontface = fonts->getfont(font);
			if (*fontface)
			{
				float x = static_cast<float>(pos.x());
				float y = static_cast<float>(pos.y());

				//glBlendFunc(GL_SRC_ALPHA, GL_ZERO);

				for (size_t i = 0; i < str.size(); i++)
				{
					int8_t ch = str[i];
					FT_GlyphSlot g = (*fontface)->glyph; 
					
					FT_UInt  glyph_index = FT_Get_Char_Index(*fontface, ch);

					if (FT_Load_Glyph(*fontface, glyph_index, FT_LOAD_DEFAULT) == FT_Err_Ok)
					{
						if (FT_Render_Glyph(g, FT_RENDER_MODE_NORMAL) == FT_Err_Ok)
						{
							glBindTexture(GL_TEXTURE_2D, texture);
							glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, g->bitmap.width, g->bitmap.rows, 0, GL_RED, GL_UNSIGNED_BYTE, g->bitmap.buffer);

							x += g->advance.x >> 6;
						}
					}
				}

				/*glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

				GLfloat left = pos.x();
				GLfloat right = pos.x() + x;
				GLfloat top = y;
				GLfloat bottom = y + 14;

				glBegin(GL_QUADS);
				glTexCoord2f(0, 0); glVertex3f(left, top, 0);
				glTexCoord2f(0, 1); glVertex3f(left, bottom, 0);
				glTexCoord2f(1, 1); glVertex3f(right, bottom, 0);
				glTexCoord2f(1, 0); glVertex3f(right, top, 0);
				glEnd();*/
			}
		}
开发者ID:pandaforks,项目名称:JourneyClient,代码行数:47,代码来源:TextWrapperGL.cpp


示例9: getlwall

	int32_t Footholdtree::getlwall(vector2d<int32_t> pos) const
	{
		int32_t ret = walls.x();
		vector2d<int32_t> ver = vector2d<int32_t>(pos.y() - 80, pos.y() - 20);
		for (map<uint16_t, Foothold>::const_iterator ftit = footholds.begin(); ftit != footholds.end(); ++ftit)
		{
			Foothold fh = ftit->second;
			if (fh.getver().overlaps(ver) && fh.iswall())
			{
				int32_t x = fh.getl();
				if (x > ret && x <= pos.x())
				{
					ret = x;
				}
			}
		}
		return ret;
	}
开发者ID:pandaforks,项目名称:JourneyClient,代码行数:18,代码来源:Footholdtree.cpp


示例10: draw

	void imagecache::draw(imgcontext ict, size_t id, D2D1_RECT_F r, float alpha, float xscale, float yscale, vector2d center)
	{
		target->SetTransform(
			D2D1::Matrix3x2F::Scale(
			D2D1::Size(xscale, yscale),
			D2D1::Point2F(
			static_cast<float>(center.x()),
			static_cast<float>(center.y())
			)));

		draw(ict, id, r, alpha);

		target->SetTransform(
			D2D1::Matrix3x2F::Scale(
			D2D1::Size(1.0f, 1.0f),
			D2D1::Point2F(
			static_cast<float>(center.x()),
			static_cast<float>(center.y())
			)));
	}
开发者ID:thisIsTooHard,项目名称:journey_client,代码行数:20,代码来源:imagecache.cpp


示例11:

	void BitmapWrapperD2D::draw(rectangle2d<int32_t> rect, float_t xscale, float_t yscale, vector2d<int32_t> center, float_t alpha) const
	{
		ID2D1BitmapRenderTarget* target = Graphics::locator.gettarget();
		if (target)
		{
			bool transform = (xscale != 1.0f) || (yscale != 1.0f);

			if (transform)
			{
				target->SetTransform(
					D2D1::Matrix3x2F::Scale(
					D2D1::Size(xscale, yscale),
					D2D1::Point2F(
					static_cast<FLOAT>(center.x()),
					static_cast<FLOAT>(center.y())
					)));
			}

			if (source)
			{
				D2D_RECT_F r = D2D1::RectF((FLOAT)rect.l(), (FLOAT)rect.t(), (FLOAT)rect.r(), (FLOAT)rect.b());
				target->DrawBitmap(source, r, alpha);
			}

			if (transform)
			{
				target->SetTransform(
					D2D1::Matrix3x2F::Scale(
					D2D1::Size(1.0f, 1.0f),
					D2D1::Point2F(
					static_cast<FLOAT>(center.x()),
					static_cast<FLOAT>(center.y())
					)));
			}
		}
	}
开发者ID:pandaforks,项目名称:JourneyClient,代码行数:36,代码来源:BitmapWrapperD2D.cpp


示例12: draw

		void draw(size_t id, rectangle2d<int16_t> rect, float xscale, 
			float yscale, vector2d<int16_t> center, float alpha) {

			if (!available(id))
				return;

			GLfloat left = center.x() + xscale * (rect.l() - center.x());
			GLfloat right = center.x() + xscale * (rect.r() - center.x());
			GLfloat top = center.y() + yscale * (rect.t() - center.y());
			GLfloat bottom = center.y() + yscale * (rect.b() - center.y());

			glBindTexture(GL_TEXTURE_2D, bitmaps[id]);
			glBegin(GL_QUADS);
			glTexCoord2f(0, 0); glVertex3f(left, top, 0);
			glTexCoord2f(0, 1); glVertex3f(left, bottom, 0);
			glTexCoord2f(1, 1); glVertex3f(right, bottom, 0);
			glTexCoord2f(1, 0); glVertex3f(right, top, 0);
			glEnd();
		}
开发者ID:sonbk21,项目名称:JourneyClient,代码行数:19,代码来源:GraphicsGL.cpp


示例13: multiply

vector2d vector2d::multiply(const vector2d& other) const
{
	vector2d multiply(afData[0] * other.x(), afData[1] * other.y());
	return multiply;
}
开发者ID:JosephRadu,项目名称:zombie_game_2,代码行数:5,代码来源:vector2d.cpp


示例14: add

vector2d vector2d::add(const vector2d& other) const
{
	vector2d add(afData[0] + other.x(), afData[1] + other.y());
	return add;
}
开发者ID:JosephRadu,项目名称:zombie_game_2,代码行数:5,代码来源:vector2d.cpp


示例15: subtract

vector2d vector2d::subtract(const vector2d& other) const
{
	vector2d subtract(afData[0] - other.x(), afData[1] - other.y());
	return subtract;
}
开发者ID:JosephRadu,项目名称:zombie_game_2,代码行数:5,代码来源:vector2d.cpp


示例16: cos

float vector2d::angle(const vector2d& other) const
{
	float angle = cos(dotProduct(other) / other.magnitude() * sqrt(afData[0] * afData[0] + afData[1] * afData[1]));
	return angle;
}
开发者ID:JosephRadu,项目名称:zombie_game_2,代码行数:5,代码来源:vector2d.cpp


示例17:

	bool vector2d::operator != (vector2d v)
	{
		return a != v.x() || b != v.y();
	}
开发者ID:swordlegend,项目名称:journey_client,代码行数:4,代码来源:vector2d.cpp


示例18: setposition

	void Player::setposition(vector2d<int32_t> pos)
	{
		phobj.fx = static_cast<float>(pos.x());
		phobj.fy = static_cast<float>(pos.y());
	}
开发者ID:pandaforks,项目名称:JourneyClient,代码行数:5,代码来源:Player.cpp


示例19: vector2d

	vector2d vector2d::operator / (vector2d v)
	{
		int x = (v.x() == 0) ? 1 : v.x();
		int y = (v.y() == 0) ? 1 : v.y();
		return vector2d(a / x, b / y);
	}
开发者ID:swordlegend,项目名称:journey_client,代码行数:6,代码来源:vector2d.cpp


示例20: main

int main()
{
    device = createDevice(EDT_OPENGL, dimension2d<u32>(screenWidth, screenHeight), 16,
                                          false, false, false, 0);
    if (!device)
        return 1;

    IVideoDriver* driver = device->getVideoDriver();

    MyEventReceiver receiver;
    device->setEventReceiver(&receiver);

    image = driver->getTexture("/home/fuyajun/Documents/irrlicht-1.7.2/media/fireball.bmp");

    position.set(0,0);
    direction.set(1,1);

    u32 then = device->getTimer()->getTime();

    while (device->run())
    {
        const u32 now = device->getTimer()->getTime();
        const f32 deltaTime = (f32)(now - then);
        then = now;

        update(deltaTime);

        driver->beginScene(true, true, SColor(255,255,255,255));

        driver->draw2DImage(image, position2d<s32>((s32)position.X, (s32)position.Y), rect<s32>(0, 0, 32, 32), 0, SColor(255, 255, 255, 255), true);

        driver->endScene();

        core::stringw str = L"x: ";
        str += target.X;
        str += ", y: ";
        str += target.Y;
        str += ", posX: ";
        str += position.X;
        str += ", posY: ";
        str += position.Y;

        device->setWindowCaption(str.c_str());
    }

    device->drop();

    return 0;
}
开发者ID:fuyajun1983cn,项目名称:myplayground,代码行数:49,代码来源:main.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ vector3类代码示例发布时间:2022-05-31
下一篇:
C++ vector2类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap