本文整理汇总了C++中Sphere::getRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::getRadius方法的具体用法?C++ Sphere::getRadius怎么用?C++ Sphere::getRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere::getRadius方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isVisible
bool PCZFrustum::isVisible( const Sphere & bound) const
{
// Check originplane if told to
if (mUseOriginPlane)
{
Plane::Side side = mOriginPlane.getSide(bound.getCenter());
if (side == Plane::NEGATIVE_SIDE)
{
Real dist = mOriginPlane.getDistance(bound.getCenter());
if (dist > bound.getRadius())
{
return false;
}
}
}
// For each extra active culling plane, see if the entire sphere is on the negative side
// If so, object is not visible
PCPlaneList::const_iterator pit = mActiveCullingPlanes.begin();
while ( pit != mActiveCullingPlanes.end() )
{
PCPlane * plane = *pit;
Plane::Side xside = plane->getSide(bound.getCenter());
if (xside == Plane::NEGATIVE_SIDE)
{
Real dist = plane->getDistance(bound.getCenter());
if (dist > bound.getRadius())
{
return false;
}
}
pit++;
}
return true;
}
示例2: find
static T find( const Sphere< T > &sphere,
const Ray< 3, T > &ray,
T lowerBound = Numeric< T >::ZERO_TOLERANCE,
T upperBound = std::numeric_limits< T >::max() )
{
Vector< 3, T > centerDiff( ray.getOrigin() - sphere.getCenter() );
T a = ray.getDirection().getSquaredMagnitude();
T b = 2 * ( centerDiff * ray.getDirection() );
T c = centerDiff.getSquaredMagnitude() - ( sphere.getRadius() * sphere.getRadius() );
T t0, t1;
if ( Root::compute( a, b, c, t0, t1 ) == 0 ) {
return -1;
}
if ( t0 < upperBound && t0 > lowerBound ) {
return t0;
}
if ( t1 < upperBound && t1 > lowerBound ) {
return t1;
}
return -1;
}
示例3: isFullyVisible
/* special function that returns true only when sphere fully fits inside the frustum. */
bool PCZFrustum::isFullyVisible(const Sphere& bound) const
{
// Check originplane if told to
if (mUseOriginPlane)
{
if (mOriginPlane.getDistance(bound.getCenter()) <= bound.getRadius() ||
mOriginPlane.getSide(bound.getCenter()) != Plane::POSITIVE_SIDE)
{
return false;
}
}
// For each extra active culling plane,
// see if the sphere is not on the positive side
// If so, object is not fully visible
PCPlaneList::const_iterator pit = mActiveCullingPlanes.begin();
while ( pit != mActiveCullingPlanes.end() )
{
PCPlane* plane = *pit;
if (plane->getDistance(bound.getCenter()) <= bound.getRadius() ||
plane->getSide(bound.getCenter()) != Plane::POSITIVE_SIDE)
{
return false;
}
pit++;
}
return true;
}
示例4: TestSpherePoly
bool TestSpherePoly ( Sphere const & A, VertexList const & verts, Plane3d const & P )
{
if(!TestSpherePlane(A,P)) return false;
float dist2 = Distance3d::Distance2PointPoly(A.getCenter(),verts);
return dist2 < (A.getRadius() * A.getRadius());
}
示例5:
ContainmentResult TestPointSphere ( Vector const & V,
Sphere const & S )
{
real radiusSquared = S.getRadius() * S.getRadius();
real distanceSquared = (V-S.getCenter()).magnitudeSquared();
return Containment1d::TestFloatLess(distanceSquared,radiusSquared);
}
示例6: View
static void View(Camera* camera, const AxisAlignedBox& aabb, const Sphere& sphere)
{
float nearClip = (sphere.getRadius() > 1)? 1 : 0.05;
float farClip = sphere.getRadius()*10000.0f;
camera->setNearClipDistance(nearClip);
camera->setFarClipDistance(farClip);
// tan (fov/2.0) = r/d => d = r/tan(fov/2.0)
float distance = sphere.getRadius()/Math::Tan(camera->getFOVy()/2.0f);
camera->setPosition(sphere.getCenter() - (camera->getDirection().normalisedCopy()*distance));
}
示例7: getCompoundShape
//==============================================================================
Sphere Sphere::getCompoundShape(const Sphere& b) const
{
const Sphere& a = *this;
/// TODO test this
/*
Vec3 centerDiff = b.center - a.center;
F32 radiusDiff = b.radius - a.radius;
Vec3 radiusDiffSqr = radiusDiff * radiusDiff;
F32 lenSqr = centerDiff.getLengthSquared();
if(radiusDiffSqrt >= 0.0)
{
if(radiusDiff >= 0.0)
{
return b;
}
else
{
return a;
}
}
else
{
F32 l = sqrt(lenSqr);
F32 t = (l + b.radius - a.radius) / (2.0 * l);
return Sphere(a.center + t * centerDiff, (l + a.radius + b.radius) /
2.0);
}
*/
Vec4 c = b.getCenter() - a.getCenter(); // Vector from one center to the
// other
F32 cLen = c.getLength();
if(cLen + b.getRadius() < a.getRadius())
{
return a;
}
else if(cLen + a.getRadius() < b.getRadius())
{
return b;
}
Vec4 bnorm = c / cLen;
Vec4 ca = (-bnorm) * a.getRadius() + a.getCenter();
Vec4 cb = (bnorm) * b.getRadius() + b.getCenter();
return Sphere((ca + cb) / 2.0, (ca - cb).getLength() / 2.0);
}
示例8: getScreenRadius
//* This only mostly works
float Camera::getScreenRadius( const Sphere &sphere, float screenWidth, float screenHeight ) const
{
Vec2f screenCenter( worldToScreen( sphere.getCenter(), screenWidth, screenHeight ) );
Vec3f orthog = mViewDirection.getOrthogonal().normalized();
Vec2f screenPerimeter = worldToScreen( sphere.getCenter() + sphere.getRadius() * orthog, screenWidth, screenHeight );
return screenPerimeter.distance( screenCenter );
}
示例9: isVisible
//-----------------------------------------------------------------------
bool Frustum::isVisible(const Sphere& sphere, FrustumPlane* culledBy) const
{
// Make any pending updates to the calculated frustum planes
updateFrustumPlanes();
// For each plane, see if sphere is on negative side
// If so, object is not visible
for (int plane = 0; plane < 6; ++plane)
{
// Skip far plane if infinite view frustum
if (plane == FRUSTUM_PLANE_FAR && mFarDist == 0)
continue;
// If the distance from sphere center to plane is negative, and 'more negative'
// than the radius of the sphere, sphere is outside frustum
if (mFrustumPlanes[plane].getDistance(sphere.getCenter()) < -sphere.getRadius())
{
// ALL corners on negative side therefore out of view
if (culledBy)
*culledBy = (FrustumPlane)plane;
return false;
}
}
return true;
}
示例10: intersects
//-----------------------------------------------------------------------
bool Math::intersects(const Sphere& sphere, const AxisAlignedBox& box)
{
if (box.isNull()) return false;
if (box.isInfinite()) return true;
// Use splitting planes
const Vector3& center = sphere.getCenter();
Real radius = sphere.getRadius();
const Vector3& min = box.getMinimum();
const Vector3& max = box.getMaximum();
// Arvo's algorithm
Real s, d = 0;
for (int i = 0; i < 3; ++i)
{
if (center.ptr()[i] < min.ptr()[i])
{
s = center.ptr()[i] - min.ptr()[i];
d += s * s;
}
else if(center.ptr()[i] > max.ptr()[i])
{
s = center.ptr()[i] - max.ptr()[i];
d += s * s;
}
}
return d <= radius * radius;
}
示例11: getScreenRadius
//* This only mostly works
float Camera::getScreenRadius( const Sphere &sphere, float screenWidth, float screenHeight ) const
{
vec2 screenCenter( worldToScreen( sphere.getCenter(), screenWidth, screenHeight ) );
vec3 orthog = normalize( orthogonal( mViewDirection ) );
vec2 screenPerimeter = worldToScreen( sphere.getCenter() + sphere.getRadius() * orthog, screenWidth, screenHeight );
return distance( screenPerimeter, screenCenter );
}
示例12:
//------------------------------------------------------------------------------
std::pair<bool, float> Math::intersects(
const Ray& ray
, const Sphere& sphere
, bool discardInside
)
{
const Vector3& raydir = ray.getDirection();
const Vector3& rayorig = ray.getOrigin() - sphere.getCenter();
float radius = sphere.getRadius();
if (rayorig.squaredLength() <= radius*radius && discardInside)
{
return std::pair<bool, float>(true, 0.0f);
}
float a = raydir.dotProduct(raydir);
float b = 2 * rayorig.dotProduct(raydir);
float c = rayorig.dotProduct(rayorig) - radius*radius;
float d = (b*b) - (4 * a * c);
if (d < 0.0f)
{
return std::pair<bool, float>(false, 0.0f);
}
else
{
float t = ( -b - Math::Sqrt(d) ) / (2 * a);
if (t < 0.0f)
{
t = ( -b + Math::Sqrt(d) ) / (2 * a);
}
return std::pair<bool, float>(true, t);
}
}
示例13:
JNIEXPORT jdouble JNICALL Java_be_kuleuven_mech_rsg_jni_RsgJNI_getSphereRadius
(JNIEnv *, jclass, jlong spherePtr) {
Sphere* sphere = reinterpret_cast<Sphere*>(spherePtr);
assert(sphere != 0);
return sphere->getRadius();
}
示例14: drawTerrain
void TerrainApp::drawTerrain()
{
mRd.getHeightsTexture().bind( 0 );
mRd.getNormalsTexture().bind( 1 );
mGradientTex.bind( 2 );
mSandNormalTex.bind( 3 );
mTerrainShader.bind();
mTerrainShader.uniform( "heightsTex", 0 );
mTerrainShader.uniform( "normalsTex", 1 );
mTerrainShader.uniform( "gradientTex", 2 );
mTerrainShader.uniform( "sandNormalTex", 3 );
mTerrainShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
mTerrainShader.uniform( "terrainScale", mTerrainScale );
mTerrainShader.uniform( "roomDims", mRoom.getDims() );
mTerrainShader.uniform( "zoomMulti", mZoomMulti );//lerp( mZoomMulti, 1.0f, mRoom.getPower() ) );
mTerrainShader.uniform( "power", mRoom.getPower() );
mTerrainShader.uniform( "eyePos", mSpringCam.getEye() );
mTerrainShader.uniform( "lightPos", mLightPos );
mTerrainShader.uniform( "fogColor", mFogColor );
mTerrainShader.uniform( "sandColor", mSandColor );
mTerrainShader.uniform( "mousePosNorm", -( mMousePosNorm - Vec2f( 0.5f, 0.5f ) ) * getElapsedSeconds() * 2.0f );
mTerrainShader.uniform( "spherePos", mSphere.getCenter() );
mTerrainShader.uniform( "sphereRadius", mSphere.getRadius() );
mTerrain.draw();
mTerrainShader.unbind();
}
示例15: evalRepulsiveForce
void SphereForce::evalRepulsiveForce(Cell & c1, const Sphere & s)
{
float overlap=fmax(((c1.getCoord().distanceTo(s.getCentroid())+c1.getRadius())-s.getRadius()),0.0f);
CVector cv;
if(overlap==0.0f) {
this->setValueXyz(cv);
return;
}
std::cout<<c1.getID()<<"---"<<overlap<<std::endl;
//cv=(c1.getCoord()/fmax(c1.getCoord().getAbsoluteMax(),1))*overlap;
cv=c1.getCoord();
cv = cv/sqrt(pow(cv.getX(),2)+pow(cv.getY(),2)+pow(cv.getZ(),2));
//cv=cv*(overlap/(c1.getCoord().distanceTo(s.getCentroid())+c1.getRadius())); // utiliser fraction de la distance pour scaler
cv.reverseSign();
c1.resetBoxCol();
/*if(strcmp(c1.getID().c_str(),"4")==1){
std::cout<<c1.getID().c_str()<<"overlap :"<<overlap<<"--"<<c1.getCoord().distanceTo(s.getCentroid())<<"\n fact : "<<(overlap/(c1.getCoord().distanceTo(s.getCentroid())+c1.getRadius()))<<"\nVecteur : "<<std::endl;
cv.print();
c1.getCoord().print();
}*/
if(cv.getX()>0.0f) c1.setWl(true);
if(cv.getX()<0.0f) c1.setWr(true);
if(cv.getY()>0.0f) c1.setHl(true);
if(cv.getY()<0.0f) c1.setHr(true);
if(cv.getZ()>0.0f) c1.setDl(true);
if(cv.getZ()<0.0f) c1.setDr(true);
this->setValueXyz((cv*overlap*REPULSIVE_CONST));
}