本文整理汇总了C++中BoundingSphere::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingSphere::valid方法的具体用法?C++ BoundingSphere::valid怎么用?C++ BoundingSphere::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingSphere
的用法示例。
在下文中一共展示了BoundingSphere::valid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expandBy
void BoundingSphere::expandBy(const BoundingSphere& sh)
{
// ignore operation if incomming BoundingSphere is invalid.
if (!sh.valid()) return;
// This sphere is not set so use the inbound sphere
if (!valid())
{
_center = sh._center;
_radius = sh._radius;
return;
}
// Calculate d == The distance between the sphere centers
double d = ( _center - sh.center() ).length();
// New sphere is already inside this one
if ( d + sh.radius() <= _radius )
{
return;
}
// New sphere completely contains this one
if ( d + _radius <= sh.radius() )
{
_center = sh._center;
_radius = sh._radius;
return;
}
// Build a new sphere that completely contains the other two:
//
// The center point lies halfway along the line between the furthest
// points on the edges of the two spheres.
//
// Computing those two points is ugly - so we'll use similar triangles
double new_radius = (_radius + d + sh.radius() ) * 0.5;
double ratio = ( new_radius - _radius ) / d ;
_center[0] += ( sh.center()[0] - _center[0] ) * ratio;
_center[1] += ( sh.center()[1] - _center[1] ) * ratio;
_center[2] += ( sh.center()[2] - _center[2] ) * ratio;
_radius = new_radius;
}
示例2: expandRadiusBy
void BoundingSphere::expandRadiusBy(const BoundingSphere& sh)
{
if (sh.valid())
{
if (valid())
{
value_type r = (sh._center-_center).length()+sh._radius;
if (r>_radius) _radius = r;
// else do nothing as vertex is within sphere.
}
else
{
_center = sh._center;
_radius = sh._radius;
}
}
}
示例3: scaleParameters
void ViroManipulator::scaleParameters( const BoundingSphere BB ){
if ( !BB.valid() ) return;
//double scaleFactor = BB.radius() * 0.001;
double scaleFactor = BB.radius() * 0.0001;
//printf("Model Scale Factor: %.4f\n", scaleFactor);
//BumpDistance = _safeBD * scaleFactor;
//AvoidanceDistance = _safeAD * scaleFactor;
Acceleration = _safeAccel * scaleFactor;
SurfaceSpeedLimiter = Acceleration * 0.1;
//_AvoidanceReaction = scaleFactor * 5e-8;
//osg::notify(ALWAYS)<<"Acceleration = " << Acceleration <<std::endl;
//osg::notify(ALWAYS)<<"Bump-Distance = " << BumpDistance <<std::endl;
//osg::notify(ALWAYS)<<"Avoidance-Distance = " << AvoidanceDistance <<std::endl;
}
示例4: computeBound
BoundingSphere Transform::computeBound() const
{
BoundingSphere bsphere = Group::computeBound();
if (!bsphere.valid()) return bsphere;
// note, NULL pointer for NodeVisitor, so compute's need
// to handle this case gracefully, normally this should not be a problem.
Matrix l2w;
computeLocalToWorldMatrix(l2w,NULL);
Vec3 xdash = bsphere._center;
xdash.x() += bsphere._radius;
xdash = xdash*l2w;
Vec3 ydash = bsphere._center;
ydash.y() += bsphere._radius;
ydash = ydash*l2w;
Vec3 zdash = bsphere._center;
zdash.z() += bsphere._radius;
zdash = zdash*l2w;
bsphere._center = bsphere._center*l2w;
xdash -= bsphere._center;
float len_xdash = xdash.length();
ydash -= bsphere._center;
float len_ydash = ydash.length();
zdash -= bsphere._center;
float len_zdash = zdash.length();
bsphere._radius = len_xdash;
if (bsphere._radius<len_ydash) bsphere._radius = len_ydash;
if (bsphere._radius<len_zdash) bsphere._radius = len_zdash;
return bsphere;
}
示例5: intersects
bool RayIntersector::intersects(const BoundingSphere& bs)
{
// if bs not valid then return false based on the assumption that the node is empty.
if (!bs.valid()) return false;
// test for _start inside the bounding sphere
Vec3d sm = _start - bs._center;
double c = sm.length2() - bs._radius * bs._radius;
if (c<0.0) return true;
// solve quadratic equation
double a = _direction.length2();
double b = (sm * _direction) * 2.0;
double d = b * b - 4.0 * a * c;
// no intersections if d<0
if (d<0.0) return false;
// compute two solutions of quadratic equation
d = sqrt(d);
double div = 1.0/(2.0*a);
double r1 = (-b-d)*div;
double r2 = (-b+d)*div;
// return false if both intersections are before the ray start
if (r1<=0.0 && r2<=0.0) return false;
// if LIMIT_NEAREST and closest point of bounding sphere is further than already found intersection, return false
if (_intersectionLimit == LIMIT_NEAREST && !getIntersections().empty())
{
double minDistance = sm.length() - bs._radius;
if (minDistance >= getIntersections().begin()->distance) return false;
}
// passed all the rejection tests so line must intersect bounding sphere, return true.
return true;
}