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

C++ Angle函数代码示例

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

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



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

示例1: GetCurrentPatch

void AI::updateSteer(AI_Car *c)
{
	c->steerlook.clear();

	const BEZIER *curr_patch_ptr = GetCurrentPatch(c->car);
	//if car has no contact with track, just let it roll
	if (!curr_patch_ptr)
	{
		if (!c->last_patch) return;
		//if car is off track, steer the car towards the last patch it was on
		//this should get the car back on track
		else curr_patch_ptr = c->last_patch;
	}

	c->last_patch = curr_patch_ptr; //store the last patch car was on

	BEZIER curr_patch = RevisePatch(curr_patch_ptr, c->use_racingline);

#ifdef VISUALIZE_AI_DEBUG
	c->steerlook.push_back(curr_patch);
#endif

	//if there is no next patch (probably a non-closed track), let it roll
	if (!curr_patch.next_patch) return;

	BEZIER next_patch = RevisePatch(curr_patch.next_patch, c->use_racingline);

	//find the point to steer towards
	float track_width = GetPatchWidthVector(curr_patch).Magnitude();
	float lookahead = track_width * LOOKAHEAD_FACTOR1 +
			c->car->GetVelocity().Magnitude() * LOOKAHEAD_FACTOR2;
	lookahead = 1.0;
	float length = 0.0;
	MATHVECTOR <float, 3> dest_point = GetPatchFrontCenter(next_patch);

	while (length < lookahead)
	{
#ifdef VISUALIZE_AI_DEBUG
		c->steerlook.push_back(next_patch);
#endif

		length += GetPatchDirection(next_patch).Magnitude()*2.0;
		dest_point = GetPatchFrontCenter(next_patch);

		//if there is no next patch for whatever reason, stop lookahead
		if (!next_patch.next_patch)
		{
			length = lookahead;
			break;
		}

		next_patch = RevisePatch(next_patch.next_patch, c->use_racingline);

		//if next patch is a very sharp corner, stop lookahead
		if (GetPatchRadius(next_patch) < LOOKAHEAD_MIN_RADIUS)
		{
			length = lookahead;
			break;
		}
	}

	MATHVECTOR <float, 3> next_position = TransformToWorldspace(dest_point);
	MATHVECTOR <float, 3> car_position = c->car->GetCenterOfMassPosition();
	MATHVECTOR <float, 3> car_orientation = direction::Forward;
	(c->car->GetOrientation()).RotateVector(car_orientation);

	MATHVECTOR <float, 3> desire_orientation = next_position - car_position;

	//car's direction on the horizontal plane
	car_orientation[2] = 0;
	//desired direction on the horizontal plane
	desire_orientation[2] = 0;

	car_orientation = car_orientation.Normalize();
	desire_orientation = desire_orientation.Normalize();

	//the angle between car's direction and unit y vector (forward direction)
	double alpha = Angle(car_orientation[0], car_orientation[1]);

	//the angle between desired direction and unit y vector (forward direction)
	double beta = Angle(desire_orientation[0], desire_orientation[1]);

	//calculate steering angle and direction
	double angle = beta - alpha;

	//angle += steerAwayFromOthers(c, dt, othercars, angle); //sum in traffic avoidance bias

	if (angle > -360.0 && angle <= -180.0)
		angle = -(360.0 + angle);
	else if (angle > -180.0 && angle <= 0.0)
		angle = - angle;
	else if (angle > 0.0 && angle <= 180.0)
		angle = - angle;
	else if (angle > 180.0 && angle <= 360.0)
		angle = 360.0 - angle;

	float optimum_range = c->car->GetOptimumSteeringAngle();
	angle = clamp(angle, -optimum_range, optimum_range);

	float steer_value = angle / c->car->GetMaxSteeringAngle();
//.........这里部分代码省略.........
开发者ID:mutnig,项目名称:vdrift,代码行数:101,代码来源:ai.cpp


示例2: Angle

double ON_AngularDimension::NumericValue()
{
  return Angle() * 180.0 / ON_PI;
}
开发者ID:cciechad,项目名称:brlcad,代码行数:4,代码来源:opennurbs_annotation.cpp


示例3: return

 bool
   PlaneGeometry::IsParallel( const PlaneGeometry *plane ) const
 {
   return ( (Angle(plane) < 10.0 * mitk::sqrteps ) || ( Angle(plane) > ( vnl_math::pi - 10.0 * sqrteps ) ) ) ;
 }
开发者ID:AndreasFetzer,项目名称:MITK,代码行数:5,代码来源:mitkPlaneGeometry.cpp


示例4: Angle

// -----------------------------------------------------------------------------
Angle Angle::operator -() const
{
	return Angle(-this->mRadian);
}
开发者ID:mkawick,项目名称:Station04,代码行数:5,代码来源:Angle.cpp


示例5: Angle

Angle Angle::fromRadians(float radians) {
    return Angle(Common::rad2deg(radians));
}
开发者ID:ZydrateJunkie,项目名称:grim_mouse,代码行数:3,代码来源:angle.cpp


示例6: Radians

	BIT_API Angle Radians( const Float64 & p_Radians )
	{
		return Angle( p_Radians );
	}
开发者ID:jimmiebergmann,项目名称:Bit-Engine,代码行数:4,代码来源:Angle.cpp


示例7: Handle

  anArrowAspect->SetLength (myArrowLength);

  gp_Pnt aLastPoint = myPnt;
  aLastPoint.Translate (myLength*gp_Vec(myDir));

  // Draw Line
  Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
  aPrims->AddVertex (myPnt);
  aPrims->AddVertex (aLastPoint);
  Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
  Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (aPrims);
  // Draw arrow
  Prs3d_Arrow::Draw (aPresentation,
                     aLastPoint,
                     myDir,
                     anArrowAspect->Angle(),
                     anArrowAspect->Length());

  // Draw text
  if (myText.Length() != 0)
  {
    gp_Pnt aTextPosition = aLastPoint;
    Prs3d_Text::Draw (aPresentation,
                      myDrawer->TextAspect(),
                      myText,
                      aTextPosition);
  }
}


void ISession_Direction::Compute (const Handle(Prs3d_Projector)& /*aProjector*/,
开发者ID:SimVascular,项目名称:OpenCASCADE,代码行数:31,代码来源:ISession_Direction.cpp


示例8: impl

BodyDescription::BodyDescription(const PhysicsContext &pc, const std::string &resource_id, const XMLResourceDocument &resources)
: impl(new BodyDescription_Impl(pc.impl->get_owner()))
{
	/* example resource entry with all parameters:
	
	<body2d name="TestBody" type="static">
        <position x="0" y="0"/>
        <rotation angle="180"/>
        <velocity x="0" y="0" angular="0"/>
        <damping linear="0" angular="0"/>
		<parameters awake="true" can_sleep="true" bullet="false" active="true" />
    </body2d>

	*/
	XMLResourceNode resource = resources.get_resource(resource_id);
	if (resource.get_type() != "body2d" && resource.get_type() != "body2d_description")
		throw Exception(string_format("Resource '%1' is not of type 'body2d' or 'body2d_description'", resource_id));

	DomNode cur_node = resource.get_element().get_first_child();

	//Body type
	std::string body_type = resource.get_element().get_attribute("type","static");
	if(body_type == "kinematic") set_type(body_kinematic);
	else if(body_type == "dynamic") set_type(body_dynamic);
	else set_type(body_static);

	while(!cur_node.is_null())
	{
		if (!cur_node.is_element()) 
			continue;
		
		DomElement cur_element = cur_node.to_element();
		std::string tag_name = cur_element.get_tag_name();

		//<position x="0" y="0"/>
		if(tag_name == "position")
		{
			float pos_x = 0.0f;
			float pos_y = 0.0f;

			if(cur_element.has_attribute("x"))
			{
				pos_x = StringHelp::text_to_float(cur_element.get_attribute("x"));
			}

			if(cur_element.has_attribute("y"))
			{
				pos_y = StringHelp::text_to_float(cur_element.get_attribute("y"));
			}

			set_position(pos_x, pos_y);
		}

		//<rotation angle="180"/>
		else if(tag_name == "rotation")
		{
			Angle angle(0.0f, angle_degrees);

			if(cur_element.has_attribute("angle"))
			{
				angle = Angle(StringHelp::text_to_float(cur_element.get_attribute("angle")), angle_degrees);
			}

			set_angle(angle);
		}

		//<velocity x="0" y="0" angular="0"/>
		else if(tag_name == "velocity")
		{
			Vec2f velocity(0.0f, 0.0f);
			Angle angular_velocity(0.0f, angle_degrees);

			if(cur_element.has_attribute("x"))
			{
				velocity.x = StringHelp::text_to_float(cur_element.get_attribute("x"));
			}

			if(cur_element.has_attribute("y"))
			{
				velocity.y = StringHelp::text_to_float(cur_element.get_attribute("y"));
			}

			if(cur_element.has_attribute("angular"))
			{
				angular_velocity = Angle(StringHelp::text_to_float(cur_element.get_attribute("angular")), angle_degrees);
			}

			set_linear_velocity(velocity);
			set_angular_velocity(angular_velocity);
		}

		//<damping linear="0" angular="0"/>
		else if(tag_name == "damping")
		{
			float linear;
			float angular;

			if(cur_element.has_attribute("linear"))
			{
				linear = StringHelp::text_to_float(cur_element.get_attribute("linear"));
//.........这里部分代码省略.........
开发者ID:Cassie90,项目名称:ClanLib,代码行数:101,代码来源:body_description.cpp


示例9: Degrees

	BIT_API Angle Degrees( const Float64 & p_Degrees )
	{
		return Angle( p_Degrees * Pi / 180.0f );
	}
开发者ID:jimmiebergmann,项目名称:Bit-Engine,代码行数:4,代码来源:Angle.cpp


示例10: AngleInt

 AngleInt( iXY &vec )
 {
     angle_int = Angle(vec).DegreesInt();
 }
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:4,代码来源:Angle.hpp


示例11: Angle

void		Inertie::upBones()
{
  _bones.angle[Bones::FOOT1] = Angle(MGRAD_CAP(MTIME * 3, -80, 50), 0);
  _bones.angle[Bones::FOOT2] = Angle(MGRAD_CAP(MTIME * 4, -80, 50), 0);
  _bones.angle[Bones::KNEE1] = Angle(MGRAD_CAP(MTIME, -35, 30), 0);
  _bones.angle[Bones::KNEE2] = Angle(MGRAD_CAP(MTIME, -65, 30), 0);

  _bones.angle[Bones::HAND1] = Angle(MGRAD_CAP(MTIME * 3, 10, 50), 0);
  _bones.angle[Bones::ELBOW1] = Angle(MGRAD_CAP(MTIME, 195, 30), 0);

  if (_player[THROW_SHURIKEN]->val())
    {
      _bones.angle[Bones::HAND2] = Angle(MGRAD_CAP(MTIME * 4, 10, 50), 0);
      _bones.angle[Bones::ELBOW2] = Angle(MGRAD_CAP(MTIME, 225, 30), 0);
    }

  _bones.angle[Bones::HEAD] = Angle(-40, 0);
  _bones.angle[Bones::BODY] = Angle(-80, 0);
  _bones.angle[Bones::BODY] = Angle(60 - _player.sy() * 20 +
      MGRAD_CAP(MTIME / 4, -60, 20), 0);
  //std::cout << MGRAD_CAP(MTIME / 4, -60, 20) << std::endl;
}
开发者ID:Yax42,项目名称:havetofly,代码行数:22,代码来源:Inertie.cpp


示例12: Angle

float RotatingLineList::CurrentAngle() {
    return Angle(centerx, centery, trackx, tracky);
}
开发者ID:neurodebian,项目名称:iv-hines,代码行数:3,代码来源:rubcurve.cpp


示例13: Angle

	Angle Vec3<Type>::angle(const Vec3<Type>& v) const
	{
		return Angle(acosf(float(dot(v) / (length()*v.length()))), angle_radians);
	}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:4,代码来源:vec3.cpp


示例14: throw

	bool DSN6File::readHeader()
		throw()
	{
		// first read the complete 512 bytes of header information
		char header[512];
		std::fstream::read(header, 512);

		if (gcount() != 512)
		{
			Log.error() << "DSN6File::readHeader(): File does not contain a proper DSN6 header. Aborting read." << std::endl;

			return false;
		}

		// to determine whether we have to swap bytes in the header (depending on the version of
		// the DSN6 - File and on the byte order on the machine) we try to reproduce the known value
		// of 100 in header[2*18]
		short int header_value = readHeaderValue_(header, 18);
		
		if (header_value != 100)
		{
			// try to change endianness
			swap_bytes_ = true;

			header_value = readHeaderValue_(header, 18);
			if (header_value != 100)
			{
				Log.error() << "DSN6File::readHeader(): Corrupt DSN6 header: header[16] != 100. Aborting read." << std::endl;
				
				return false;
			}
		}

		header_value = readHeaderValue_(header, 0);
		start_.x = (float)header_value;

		header_value = readHeaderValue_(header, 1);
		start_.y = (float)header_value;

		header_value = readHeaderValue_(header, 2);
		start_.z = (float)header_value;

		header_value = readHeaderValue_(header, 3);
		extent_.x = (float)header_value;

		header_value = readHeaderValue_(header, 4);
		extent_.y = (float)header_value;

		header_value = readHeaderValue_(header, 5);
		extent_.z = (float)header_value;

		header_value = readHeaderValue_(header, 6);
		sampling_rate_.x = (float)header_value;

		header_value = readHeaderValue_(header, 7);
		sampling_rate_.y = (float)header_value;

		header_value = readHeaderValue_(header, 8);
		sampling_rate_.z = (float)header_value;

		header_value = readHeaderValue_(header, 17);	
		cell_scaling_ = (float)header_value;

		header_value = readHeaderValue_(header, 9);
		crystal_dimension_.x = (float)header_value / (cell_scaling_ * sampling_rate_.x);  

		header_value = readHeaderValue_(header, 10);
		crystal_dimension_.y = (float)header_value / (cell_scaling_ * sampling_rate_.y);

		header_value = readHeaderValue_(header, 11);
		crystal_dimension_.z = (float)header_value / (cell_scaling_ * sampling_rate_.z);

		header_value = readHeaderValue_(header, 12);
		alpha_ = Angle((float)header_value / cell_scaling_, false);

		header_value = readHeaderValue_(header, 13);
		beta_  = Angle((float)header_value / cell_scaling_, false);

		header_value = readHeaderValue_(header, 14);
		gamma_ = Angle((float)header_value / cell_scaling_, false);

		header_value = readHeaderValue_(header, 15);
		prod_ = (float)header_value / 100.;

		header_value = readHeaderValue_(header, 16);
		plus_ = (float)header_value;

		// convert from grid space to cartesian coordinates (inspired by the VMD code :-) )
		Vector3 x_tmp(crystal_dimension_.x, 0., 0.);
		Vector3 y_tmp(cos(gamma_.toRadian()), sin(gamma_.toRadian()), 0.);
		y_tmp *= crystal_dimension_.y;
		Vector3 z_tmp( cos(beta_.toRadian()), 
									(cos(alpha_.toRadian()) - cos(beta_.toRadian())*cos(gamma_.toRadian())) / sin(gamma_.toRadian()),
									0.);
		z_tmp.z = sqrt(1.0 - z_tmp.x*z_tmp.x - z_tmp.y*z_tmp.y);
		z_tmp *= crystal_dimension_.z;

		origin_.x = x_tmp.x * start_.x + y_tmp.x * start_.y + z_tmp.x * start_.z;
		origin_.y = y_tmp.y * start_.y + z_tmp.y * start_.z;
		origin_.z = z_tmp.z * start_.z;
//.........这里部分代码省略.........
开发者ID:Indicator,项目名称:raptorx-zy,代码行数:101,代码来源:DSN6File.C


示例15: rotate

void TestApp::test_vector2(void)
{
    Console::write_line(" Header: cl_vector.h");
    Console::write_line("  Class: Vec2");

    Console::write_line("   Function: rotate()");
    {
        Vec2i test_a;
        Vec2i hotspot(1,3);

        test_a = Vec2i(4,5);
        test_a.rotate(hotspot, Angle(0, angle_degrees));
        if (test_a != Vec2i(4, 5))  fail();

        test_a = Vec2i(4,5);
        test_a.rotate(hotspot, Angle(90, angle_degrees));
        if (test_a != Vec2i(-1, 6))  fail();

        test_a = Vec2i(4,5);
        test_a.rotate(hotspot, Angle(180, angle_degrees));
        if (test_a != Vec2i(-2, 1))  fail();

        test_a = Vec2i(4,5);
        test_a.rotate(hotspot, Angle(270, angle_degrees));
        if (test_a != Vec2i(3, 0))  fail();

        test_a = Vec2i(4,5);
        test_a.rotate(hotspot, Angle(360, angle_degrees));
        if (test_a != Vec2i(4, 5))  fail();

        test_a = Vec2i(4,5);
        test_a.rotate(Vec2i(0,0), Angle(180, angle_degrees));
        if (test_a != Vec2i(-4, -5))  fail();

    }

    Console::write_line("   Function: distance()");
    {
        Vec2d test_a(2.0,3.0);
        Vec2d test_b(3.0,4.0);

        if (test_a.distance(test_b) != sqrt(1.0 + 1.0 ))  fail();
    }
    Console::write_line("   Function: normalize()");
    {
        Vec2d testi(3.0,4.0);
        testi.normalize();
        if (testi !=  Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0)))  fail();
    }

    Console::write_line("   Function: static normalize()");
    {
        Vec2d testi(3.0,4.0);
        if (Vec2d::normalize(testi) !=  Vec2d(3.0/sqrt(25.0), 4.0/sqrt(25.0)))  fail();
    }

    Console::write_line("   Function: length()");
    {
        Vec2d testi(3.0,4.0);
        if (testi.length() != sqrt(25.0 ))  fail();
    }

    Console::write_line("   Function: dot()");
    {
        Vec2d test_a(3.0,4.0);
        Vec2d test_b(13.0,14.0);
        if (test_a.dot(test_b) != ((3.0 * 13.0)+ (4.0*14.0)))  fail();
    }

    Console::write_line("   Function: operator += (const Vec2<Type>& vector)");
    {
        Vec2d testd(2.5, 3.5);
        testd += Vec2d(1.0, 2.0);

        if (testd.x != 3.5) fail();
        if (testd.y != 5.5) fail();

        Vec2i testi(2, 3);
        testi += Vec2i(1, 2);
        if (testi.x != 3) fail();
        if (testi.y != 5) fail();

    }

    Console::write_line("   Function: operator += ( Type value)");
    {
        Vec2d testd(2.5, 3.5);
        double valued = 2.0;
        testd += valued;

        if (testd.x != 4.5) fail();
        if (testd.y != 5.5) fail();

        Vec2i testi(2, 3);
        int valuei = 2;
        testi += valuei;
        if (testi.x != 4) fail();
        if (testi.y != 5) fail();

    }
//.........这里部分代码省略.........
开发者ID:doughdemon,项目名称:ClanLib,代码行数:101,代码来源:test_vector.cpp


示例16: Angle

inline const Angle operator - ( const Angle & angle ) {
    return Angle( -angle.radian() );
}
开发者ID:0xd0d9e,项目名称:anthracitarium,代码行数:3,代码来源:angle.hpp


示例17: Angle

Angle Angle::operator / (const double dd)
{
    return Angle(this->toDouble() / dd);
}
开发者ID:namangogia2,项目名称:Arduino,代码行数:4,代码来源:Angle.cpp


示例18: Angle

 float Angle(const sf::Vector2f &v1, const sf::Vector2f &v2)
 {
     return Angle(v1.x, v1.y, v2.x, v2.y);
 }
开发者ID:xabufr,项目名称:monopoly,代码行数:4,代码来源:trigo.cpp


示例19: Angle

void PeptideCapProcessor::optimizeCapPosition(Chain& chain, bool start)
{
    Vector3 translation;
    Atom* axis   = NULL;
    Residue* cap = NULL;
    std::vector<Atom*> a;
    std::vector<Atom*> b;

    Size nr = chain.countResidues();

    // cap at the beginning of a peptide
    if (start)
    {
        // put ACE-C to the center
        for (AtomIterator it = chain.getResidue(1)->beginAtom(); +it; ++it)
        {
            if (it->getName() == "N")
            {
                translation = it->getPosition();
            }

            b.push_back(&*it);
        }

        cap = chain.getResidue(0);
        for (AtomIterator it = cap->beginAtom(); +it; ++it)
        {
            a.push_back(&*it);
            if (it->getName() == "C")
            {
            axis = &*it;
        }
    }
}
//cap at the end of a peptide
else
{
    for (AtomIterator it = chain.getResidue(nr-2)->beginAtom(); +it; ++it)
    {
        if (it->getName() == "C")
        {
            translation = it->getPosition();
        }

        b.push_back(&*it);
    }

    cap = chain.getResidue(nr-1);
    for (AtomIterator it = cap->beginAtom(); +it; ++it)
    {
        a.push_back(&*it);
        if (it->getName() == "N")
        {
            axis = &*it;
        }
    }
}

//translate the anchor to origin
TranslationProcessor tlp;
tlp.setTranslation(translation*-1.0);
chain.apply(tlp);

//try all torsions
float largest_distance = 0.0;
float tmp_distance = 0.0;
float torsion      = 0.0;
float step         = 2.0;

TransformationProcessor tfp;
Matrix4x4 m;
m.setRotation( Angle(step, false), axis->getPosition());
tfp.setTransformation(m);

for (Position r = step; r <= 360; r+=step)
{
    cap->apply(tfp);

    tmp_distance = computeDistance(a,b);

    if (largest_distance < tmp_distance)
    {
        largest_distance = tmp_distance;
        torsion = r;
    }
}

//apply best rotation angle
m.setRotation( Angle(torsion, false), axis->getPosition());
tfp.setTransformation(m);
cap->apply(tfp);

//now translate the protein back
tlp.setTranslation(translation);
chain.apply(tlp);
}
开发者ID:pbrach,项目名称:ball,代码行数:96,代码来源:peptideCapProcessor.C



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ AngleDelta函数代码示例发布时间:2022-05-30
下一篇:
C++ Android_JNI_GetEnv函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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