本文整理汇总了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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}