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

C++ vec2类代码示例

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

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



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

示例1: AngleBetween

float AngleBetween(const vec2 &a, const vec2 &b)
{
    float dotProd = a.dotProduct(b);
    float cosine = dotProd / (a.length() * b.length());

    return RadToDeg(acos(cosine));
}
开发者ID:flaming0,项目名称:software-renderer,代码行数:7,代码来源:math_utils.cpp


示例2: draw_pt

 void
 draw_pt(const vec2 &pt, float size, const vec4 &color)
 {
   gl::Uniform(m_pts_pos_loc, vec3(pt.x(), pt.y(), size));
   gl::Uniform(m_pts_color_loc, color);
   glDrawArrays(GL_POINTS, 0, 1);
 }
开发者ID:cjcappel,项目名称:fastuidraw,代码行数:7,代码来源:main.cpp


示例3: globalAngle

inline static qreal globalAngle( const vec2 &v )
{
  //assuming v is normalized
  qreal cosa = v.x();
  qreal sina = -v.y();
  return sina >= 0.0 ? acosf(cosa) : 2.0*PI - acosf(cosa);
}
开发者ID:DSastre,项目名称:supercollider,代码行数:7,代码来源:prim_QPen.cpp


示例4: angle

float angle (const vec2& arg1, const vec2& arg2)
{
			
			float skal = il_skal(arg1, arg2)/(arg1.length()*arg2.length());
			skal = abs(acos(skal))*sgn(arg1, arg2);
			return skal;
}
开发者ID:scoiatael,项目名称:PGKFirst,代码行数:7,代码来源:matrices2d.hpp


示例5:

inline vec2 operator*(const vec2& v, const mat2& m)
{
    vec2 t;
    t.x() = v.x()*m.e(0,0) + v.y()*m.e(0,1);
    t.y() = v.x()*m.e(1,0) + v.y()*m.e(1,1);
    return t;
}
开发者ID:cody82,项目名称:simquadcopter,代码行数:7,代码来源:mat2.hpp


示例6: wanted_direction

void Automan::OnTick() {
	Parent::OnTick();

	cure::ContextObject* car = manager_->GetObject(car_id_, true);
	if (!car) {
		manager_->PostKillObject(GetInstanceId());
		return;
	}
	if (!car->IsLoaded()) {
		return;
	}
	car->SetEnginePower(0, 1);
	const vec2 wanted_direction(direction_.x, direction_.y);
	const vec3 car_direction3d = car->GetOrientation()*vec3(0,1,0);
	const vec2 car_direction(car_direction3d.x, car_direction3d.y);
	const float angle = wanted_direction.GetAngle(car_direction);
	car->SetEnginePower(1, angle);

	if (car->GetVelocity().GetLengthSquared() < 1.0f) {
		still_timer_.TryStart();
		if (still_timer_.QueryTimeDiff() > 4.0f) {
			cure::Health::Set(car, 0);
		}
	} else {
		still_timer_.Stop();
	}
}
开发者ID:highfestiva,项目名称:life,代码行数:27,代码来源:automan.cpp


示例7: build

void KDTree::build(const vec2& iLats, const vec2& iLons) {
    mLats = iLats;
    mLons = iLons;
    if(iLats.size() != iLons.size())
        Util::error("Cannot initialize KDTree, lats and lons not the same size");

    size_t nLat = iLats.size();
    if(nLat == 0)
        Util::error("Cannot initialize KDTree, no valid locations");

    size_t nLon = iLats[0].size();
    if(nLon == 0)
        Util::error("Cannot initialize KDTree, no valid locations");

    indexdVec lons(nLon*nLat);

    indexdVec::iterator currLon = lons.begin();
    size_t to = -1;
    for(size_t i = 0; i < iLats.size(); ++i) {
        for(size_t j = 0; j < iLats[0].size(); ++j) {
            if(Util::isValid(iLons[i][j]) && Util::isValid(iLats[i][j])) {
                *(currLon++) = Indexed(iLons[i][j], iLats[i][j], i, j);
                ++to;
            }
        }
    }

    if(to == -1) {
        Util::error("Cannot initialize KDTree, no valid locations");
    }
    if(to >= 0) subTree(lons, 0, to, true, NULL, mRoot);
}
开发者ID:cskarby,项目名称:gridpp,代码行数:32,代码来源:KDTree.cpp


示例8: x

 bool operator<(const vec2& v) const
 {
   if (x() != v.x())
     return x() < v.x();
   else
     return y() < v.y();
 }
开发者ID:cody82,项目名称:simquadcopter,代码行数:7,代码来源:vec2.hpp


示例9: yaw_vector

void Launcher::GetBallisticData(const vec3& position1, const vec3& position2,
	float pitch, float& guide_pitch, float& guide_yaw, float &time) const {
	const vec3 delta = position1 - position2;
	const vec2 yaw_vector(delta.x, delta.y);
	guide_yaw = vec2(0, 1).GetAngle(yaw_vector);

	const float h = delta.z;
	const float v = game_->GetMuzzleVelocity();
	const float vup = v * ::cos(pitch);
	// g*t^2/2 - vup*t + h = 0
	//
	// Quaderatic formula:
	// ax^2 + bx + c = 0
	// =>
	//     -b +- sqrt(b^2 - 4ac)
	// x = ---------------------
	//             2a
	const float a = +9.82f/2;
	const float b = -vup;
	const float c = +h;
	const float b2 = b*b;
	const float _4ac = 4*a*c;
	if (b2 < _4ac) {	// Does not compute.
		guide_pitch = -PIF/4;
	} else {
		const float t = (-b + sqrt(b2 - _4ac)) / (2*a);
		//deb_assert(t > 0);
		time = t;
		const float vfwd = yaw_vector.GetLength() / t;
		guide_pitch = -::atan(vfwd/vup);
		if (guide_pitch < pitch) {	// Aiming downwards?
			guide_pitch += (guide_pitch-pitch);	// Tss! Homebrew... seems to be working somewhat! :)
		}
	}
}
开发者ID:highfestiva,项目名称:life,代码行数:35,代码来源:launcher.cpp


示例10: parseTransform

bool esvg::Polyline::parseXML(const exml::Element& _element, mat2& _parentTrans, vec2& _sizeMax) {
	// line must have a minimum size...
	m_paint.strokeWidth = 1;
	if (_element.exist() == false) {
		return false;
	}
	parseTransform(_element);
	parsePaintAttr(_element);
	
	// add the property of the parrent modifications ...
	m_transformMatrix *= _parentTrans;
	
	std::string sss1 = _element.attributes["points"];
	if (sss1.size() == 0) {
		ESVG_ERROR("(l "<<_element.getPos()<<") polyline: missing points attribute");
		return false;
	}
	_sizeMax.setValue(0,0);
	ESVG_VERBOSE("Parse polyline : \"" << sss1 << "\"");
	const char* sss = sss1.c_str();
	while ('\0' != sss[0]) {
		vec2 pos;
		int32_t n;
		if (sscanf(sss, "%f,%f %n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
			m_listPoint.push_back(pos);
			_sizeMax.setValue(std::max(_sizeMax.x(), pos.x()),
			                  std::max(_sizeMax.y(), pos.y()));
			sss += n;
		} else {
			break;
		}
	}
	return true;
}
开发者ID:atria-soft,项目名称:esvg,代码行数:34,代码来源:Polyline.cpp


示例11: contains

 bool Rectangle::contains(const vec2 &pt){
     if(pt.x() > pts[0].x() &&pt.x() < pts[1].x()
             && pt.y() > pts[0].y() && pt.y()< pts[3].y()){
         return true;
     }
     return false;

 }
开发者ID:mmoconnor23,项目名称:potterswheel,代码行数:8,代码来源:rectangle.cpp


示例12:

void etk::Matrix2::scale(const vec2& _vect) {
	m_mat[0] *= _vect.x();
	m_mat[1] *= _vect.x();
	m_mat[2] *= _vect.x();
	m_mat[4] *= _vect.y();
	m_mat[3] *= _vect.y();
	m_mat[5] *= _vect.y();
}
开发者ID:atria-soft,项目名称:etk,代码行数:8,代码来源:Matrix2.cpp


示例13: SetCamera

void SetCamera ( vec2 corner1, vec2 corner2, float rotation )
{
	matrix2x3 projection ( matrix2x3::Ortho(corner1.X(), corner2.X(), corner1.Y(), corner2.Y()) );
	if (fabs(rotation) > 0.00004f)
		projection *= matrix2x3::Rotation(rotation);
	Matrices::SetProjectionMatrix(projection);
	cameraCorner1 = corner1;
	cameraCorner2 = corner2;
}
开发者ID:prophile,项目名称:xsera,代码行数:9,代码来源:Graphics.cpp


示例14: cmdUIDrawTexturedQuad

void cmdUIDrawTexturedQuad(struct Cmd* pCmd, UIManager* pUIManager, const vec2& position, const vec2& size, Texture* pTexture)
{
	UNREF_PARAM(pCmd);
	// the last variable can be used to create a border
	TexVertex pVertices[] = { MAKETEXQUAD(position.getX(), position.getY(), position.getX() + size.getX(), position.getY() + size.getY(), 0) };
	int nVertices = sizeof(pVertices) / sizeof(pVertices[0]);
	float4 color = { 1.0f, 1.0f, 1.0f, 1.0f };
	pUIManager->pUIRenderer->drawTextured(PRIMITIVE_TOPO_TRI_STRIP, pVertices, nVertices, pTexture, &color);
}
开发者ID:VladSerhiienko,项目名称:The-Forge,代码行数:9,代码来源:UIManager.cpp


示例15: vec2

vec2 matrix2x3::operator* ( const vec2& srcv2 ) const
{
	float ix, iy, ox, oy;
	ix = srcv2.X();
	iy = srcv2.Y();
	ox = (ix * _m11) + (iy * _m12) + _tX;
	oy = (ix * _m21) + (iy * _m22) + _tY;
	return vec2(ox, oy);
}
开发者ID:adam000,项目名称:Apollo,代码行数:9,代码来源:Matrix2x3.cpp


示例16: unit_vec2

 explicit unit_vec2(const vec2<T>& r) {
     T mag = r.magnitude();
     if(mag == T(0)) {
         x() = 0;
         y() = 0;
     } else {
         x() = r.x()/mag;
         y() = r.y()/mag;
     }
 }
开发者ID:gmaslov,项目名称:ga-nn-followers,代码行数:10,代码来源:vec.hpp


示例17: vec2

float TerrainRenderer::Patch::height(vec2 v) const
{
    v -= _param.offset.to<2>();
    v /= _param.size;

    std::swap(v.x(), v.y());

    v *= vec2(_gpuHeightData.size().x()-1, _gpuHeightData.size().y()-1);
    return _gpuHeightData.getLinear(v).z() * _param.zscale;
}
开发者ID:williamallas,项目名称:TIMEngine2,代码行数:10,代码来源:TerrainRenderer.cpp


示例18: draw

	void draw(const vec2& where, char offsetz) const
	{
		vec2 end = get_end();
		glColor3f(1.,1.,1.);
		glLoadIdentity();
		glBegin(GL_LINES);
		glVertex3f(where.get_x(),where.get_y(), (offsetz)*OFFSET_SIZE);
		glVertex3f(end.get_x()+where.get_x(), end.get_y()+where.get_y(), (offset+offsetz)*OFFSET_SIZE);
		glEnd();
	}
开发者ID:scoiatael,项目名称:PGKFirst,代码行数:10,代码来源:stickman.hpp


示例19: signed_angle_between

plane_angle signed_angle_between(const vec2<L>& lhs, const vec2<R>& rhs) {
    dimensionless sgn;
    // TODO: isn't there a better way to compute this?
    if(angle_difference(lhs.angle(), rhs.angle()) < plane_angle(0)) {
        sgn = -1;
    } else {
        sgn = 1;
    }
    return sgn*acos(unit_vec2(lhs).dot(unit_vec2(rhs)));
}
开发者ID:gmaslov,项目名称:ga-nn-followers,代码行数:10,代码来源:vec.hpp


示例20:

void
JellyfishPrivate::update_viewport(const vec2& vp)
{
    if (viewport_.x() == vp.x() && viewport_.y() == vp.y())
    {
        return;
    }
    viewport_ = vp;
    projection_.loadIdentity();
    projection_.perspective(30.0, viewport_.x()/viewport_.y(), 20.0, 120.0);    
}
开发者ID:Gnurou,项目名称:glmark2,代码行数:11,代码来源:scene-jellyfish.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ vec2f类代码示例发布时间:2022-05-31
下一篇:
C++ vec1类代码示例发布时间: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