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


C++ Sphere::GetRadius方法代码示例

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


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

示例1: DistanceFromSphere

float Plane::DistanceFromSphere( const Sphere & sphere ) const
{
	float distance = Normal() * sphere.GetCenter() + d;

	if ( distance > sphere.GetRadius() ) {
		return distance - sphere.GetRadius();
	}
	if ( distance < -sphere.GetRadius() ) {
		return distance + sphere.GetRadius();
	} else {
		return 0.0f;
	}
}
开发者ID:romart,项目名称:Qoom,代码行数:13,代码来源:Plane.cpp

示例2: FromSphere

Box Box::FromSphere(const Sphere &sphere)
{
    Box b;
    b.SetMin(sphere.GetCenter() - Vector3(sphere.GetRadius()));
    b.SetMax(sphere.GetCenter() + Vector3(sphere.GetRadius()));
    return b;
}
开发者ID:sephirot47,项目名称:Bang,代码行数:7,代码来源:Box.cpp

示例3: Update

void TextView::Update(Observable* o_val)
{
	Sphere *sphere = (Sphere*)o_val;
	cout << "The radius of the sphere is " << sphere->GetRadius() << endl;
	cout << "The area of the sphere is " << sphere->GetArea() << endl;
	cout << "The volume of the sphere is " << sphere->GetVolume() << endl;
}
开发者ID:2015cnugithub,项目名称:2151002052ChenYu,代码行数:7,代码来源:TextView.cpp

示例4: RaySphereIntersection

bool Renderer::RaySphereIntersection(Ray ray, Sphere sphere)
{
	Vector d = ray.GetDirection();
	Vector e = ray.GetOrigin();
	Vector c = sphere.GetCenter();
	int R = sphere.GetRadius();

	float discriminant = (d ^ (e - c)) * (d ^ (e - c)) - ((d ^ d) * (((e - c) ^ (e - c)) - R * R));

	if(discriminant >= 0.0)
		return true;

	return false;
}
开发者ID:DiMasta,项目名称:Raytracing_edX,代码行数:14,代码来源:Rederer.cpp

示例5: Update

void InternalPhysics::Update()
{
	int objectNumber = 0;

	// Testing collisions after computing following positions
	list<Object*>::iterator anObject = mCollisionalObjects.begin();
	while( anObject != mCollisionalObjects.end() ) //Test collisions
	{
		// We don't test collisions for planes
		if( (*anObject)->GetType() != PLANE)
		{
			// If it's a moving shape, we test collisions
			TestCollision(&anObject,objectNumber);
		}
		++anObject;
		objectNumber++;

	}


	//Managing the collisions
	list<Intersection>::iterator anIntersection = mListIntersection.begin();
	while( anIntersection != mListIntersection.end() )
	{
		// Object getting
		Object* A,*B;
		A = (*anIntersection).mA;
		B = (*anIntersection).mB;

		// Type getting
		int typeA = A->GetType();
		int typeB = B->GetType();

		// Managing the sphere/sphere collision
		if(	typeA == SPHERE	&&	typeB == SPHERE )
		{
			ManageSphereSphereCollision	( (Sphere*) A, (Sphere*) B);
		}
		// Managing the sphere/plane collision
		if( typeA == SPHERE	&&	typeB == PLANE)
		{
			ManageSpherePlaneCollision( (Sphere*) A, (Plane *) B);
		}

		// Moving to the next one
		anIntersection++;
	}
	mListIntersection.clear();


	// Updating speeds and positions
	anObject = mCollisionalObjects.begin();
	while( anObject != mCollisionalObjects.end() )
	{
		// Only if not a plane
		if( (*anObject)->GetType() != PLANE )
		{

			(*anObject)->SetVelocity( (*anObject)->GetNewVelocity() );
			(*anObject)->SetPosition( (*anObject)->GetNewPosition() );

			// Adding a break force
			if( (*anObject)->GetType() == SPHERE )
			{
				Vector3 velocity = (*anObject)->GetVelocity();
				Sphere *sphere = (Sphere*)(*anObject);
				// Applying Stockes lay
				Vector3 airBreak = -6.0 * Inertia::Pi * Inertia::Nu * sphere->GetRadius() * velocity;
				Vector3 applicationPoint(sphere->GetPosition()+velocity.Normalize()*sphere->GetRadius());
				Force airBreak2(airBreak,applicationPoint);
				sphere->AddNewVariableForce(airBreak2);
			}


		}
		++anObject;
	}

}
开发者ID:AnisB,项目名称:Inertia,代码行数:79,代码来源:InternalPhysics.cpp


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