本文整理汇总了C++中Sphere::center方法的典型用法代码示例。如果您正苦于以下问题:C++ Sphere::center方法的具体用法?C++ Sphere::center怎么用?C++ Sphere::center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere::center方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sqr
bool et::intersect::sphereSphere(const Sphere& s1, const Sphere& s2, vec3* amount)
{
vec3 dv = s2.center() - s1.center();
float distance = dv.dotSelf();
float radiusSum = s1.radius() + s2.radius();
bool collised = (distance <= sqr(radiusSum));
if (amount && collised)
*amount = dv.normalized() * (radiusSum - std::sqrt(distance));
return collised;
}
示例2: p
bool et::intersect::sphereTriangle(const Sphere& s, const vec3& sphereVelocity, const triangle& t,
vec3& point, vec3& normal, float& penetration, float& intersectionTime)
{
plane p(t);
if (p.distanceToPoint(s.center()) <= s.radius())
return sphereTriangle(s, t, point, normal, penetration);
vec3 triangleNormal = p.normal();
float NdotV = dot(triangleNormal, sphereVelocity);
if (NdotV >= 0.0f) return false;
intersectionTime = (s.radius() + p.equation.w - dot(triangleNormal, s.center())) / NdotV;
vec3 movedCenter = s.center() + intersectionTime * sphereVelocity;
return sphereTriangle(movedCenter, s.radius(), t, point, normal, penetration);
}
示例3: export_Sphere
inline VLXValue export_Sphere(const Sphere& sphere)
{
VLXValue value ( new VLXStructure("<vl::Sphere>") );
*value.getStructure() << "Center" << vlx_toValue(sphere.center());
*value.getStructure() << "Radius" << sphere.radius();
return value;
}
示例4: Intersects
bool Frustum::Intersects( const Sphere &sphere ) const {
// Has the frustum planes been built?
if (!initialized_) { ASSERT(false); return false; }
// Are the frustum planes up to date?
if (needs_rebuild_) {
// TODO Warn them!
}
// For each plane, see if sphere is on negative side
// If so, object is not visible
for (int32 plane = 0; plane < 6; ++plane) {
// Skip far plane if infinite view frustum
if ((plane == FRUSTUM_PLANE_FAR) && far_distance_ == 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 (frustum_planes_[plane].Distance(sphere.center()) < -sphere.radius()) {
// ALL corners on negative side therefore out of view
return false;
}
}
return true;
}
示例5: distance
Real Sphere::distance (const Sphere & other_sphere) const
{
libmesh_assert_greater ( this->radius(), 0. );
libmesh_assert_greater ( other_sphere.radius(), 0. );
const Real the_distance = (this->center() - other_sphere.center()).norm();
return the_distance - (this->radius() + other_sphere.radius());
}
示例6:
bool et::intersect::sphereTriangles(const Sphere& s, const triangle* triangles,
size_t triangleCount, vec3& point, vec3& normal, float& penetration)
{
for (size_t i = 0; i < triangleCount; ++i)
{
if (sphereTriangle(s.center(), s.radius(), triangles[i], point, normal, penetration))
return true;
}
return false;
}
示例7:
bool Frustum<NumericT>::intersects_with (const Sphere<3, NumericT> & s) const
{
for (dimension i = 0; i < 6; ++i) {
NumericT d = _planes[i].distance_to_point(s.center());
if (d <= -s.radius())
return false;
}
return true;
}
示例8: cull
bool cull(const Sphere& sphere) const
{
// null spheres are always visible
if (sphere.isNull())
return false;
for(unsigned i=0; i<planes().size(); ++i)
{
if ( plane(i).distance(sphere.center()) > sphere.radius() )
return true;
}
return false;
}
示例9: includes
/** Returns true if a sphere contains the specified sphere. */
bool includes(const Sphere& other) const
{
if (isNull())
return false;
else
if (other.isNull())
return true;
else
{
real distance = (center() - other.center()).length();
return radius() >= distance + other.radius();
}
}
示例10: createDistanceConstraints
void createDistanceConstraints(SphereTree &i_stree,
const std::vector<DistanceGeometry *>& i_shapes,
std::vector<DistanceConstraint *>& o_consts)
{
// delete old constraints
for (unsigned int i=0; i<o_consts.size(); i++){
// TODO :
delete o_consts[i];
}
o_consts.clear();
int nconsts=0;
double ds = 0.005; // AR
//double ds = 0.0;
for (unsigned int i=0; i<i_shapes.size(); i++){
std::vector<hrp::Vector3> spheres;
Sphere *s = dynamic_cast<Sphere *>(i_shapes[i]);
CappedCylinder *cp = dynamic_cast<CappedCylinder *>(i_shapes[i]);
if (s){
i_stree.collectSpheres(s->center(), s->radius(), DI,
spheres);
#if 1
for (unsigned int j=0; j<spheres.size(); j++){
Sphere *o = new Sphere(i_stree.link(), spheres[j], i_stree.radius());
DistancePair *dp = new SphereSpherePair(s, o);
DistanceConstraint *dc = new DistanceConstraint(dp);
dc->securityDistance(ds);
dc->influenceDistance(DI);
dc->xi(0.5*0.005);
o_consts.push_back(dc);
}
#endif
}else if (cp){
i_stree.collectSpheres(cp->point(), Vector3(cp->point()+cp->vector()),
cp->radius(), DI, spheres);
#if 1
for (unsigned int j=0; j<spheres.size(); j++){
Sphere *o = new Sphere(i_stree.link(), spheres[j], i_stree.radius());
DistancePair *dp = new CappedCylinderSpherePair(cp, o);
DistanceConstraint *dc = new DistanceConstraint(dp);
dc->securityDistance(ds);
dc->influenceDistance(DI);
dc->xi(0.5*0.005);
o_consts.push_back(dc);
}
#endif
}
nconsts += spheres.size();
}
}
示例11: findBin
size_t findBin(Vector3<FloatType> pos)
{
Vector3<FloatType> origin =
boundingSphere.center() - boundingSphere.getRadius();
FloatType divisionWidth = (2 * boundingSphere.getRadius())
/ (divisions + 1);
Vector3<FloatType> normalizedPos = pos - origin;
size_t x = floor(normalizedPos.getX() / divisionWidth);
size_t y = floor(normalizedPos.getY() / divisionWidth);
size_t z = floor(normalizedPos.getZ() / divisionWidth);
size_t index = z + (divisions +1)*y + (divisions+1)*(divisions+1)*x;
if (index >= size) { return size - 1; }
return index;
}
示例12: dot
bool et::intersect::raySphere(const ray3d& r, const Sphere& s, vec3* ip1, vec3* ip2)
{
vec3 dv = r.origin - s.center();
float b = dot(r.direction, dv);
if (b > 0.0) return false;
float d = sqr(b) - dv.dotSelf() + sqr(s.radius());
if (d < 0.0f) return false;
d = std::sqrt(d);
if (ip1)
*ip1 = r.origin - (b + d) * r.direction;
if (ip2)
*ip2 = r.origin + (d - b) * r.direction;
return true;
}
示例13: sphereBox
bool et::intersect::sphereAABB(const Sphere& s, const AABB& b)
{
return sphereBox(s.center(), s.radius(), b.center, b.dimension);
}
示例14: Surface
Sphere::Sphere (const Sphere & other_sphere) :
Surface()
{
this->create_from_center_radius (other_sphere.center(),
other_sphere.radius());
}
示例15: sphereTriangle
bool et::intersect::sphereTriangle(const Sphere& s, const triangle& t, vec3& point, vec3& normal,
float& penetration)
{
return sphereTriangle(s.center(), s.radius(), t, point, normal, penetration);
}