Class Sphere

Inheritance Relationships

Base Type

Class Documentation

class Sphere : public bodies::Body

Definition of a sphere.

Public Functions

inline Sphere()
inline Sphere(const shapes::Shape *shape)
explicit Sphere(const BoundingSphere &sphere)
~Sphere() override = default
virtual std::vector<double> getDimensions() const override

Get the radius of the sphere.

virtual std::vector<double> getScaledDimensions() const override

Get the dimensions associated to this body (scaled and padded)

virtual bool containsPoint(const Eigen::Vector3d &p, bool verbose = false) const override

Check if a point is inside the body. Surface points are included.

virtual double computeVolume() const override

Compute the volume of the body. This method includes changes induced by scaling and padding.

virtual bool samplePointInside(random_numbers::RandomNumberGenerator &rng, unsigned int max_attempts, Eigen::Vector3d &result) const override

Sample a point that is included in the body using a given random number generator.

Sometimes multiple attempts need to be generated. The function terminates with failure (returns false) after max_attempts attempts. If the call is successful (returns true) the point is written to result

virtual void computeBoundingSphere(BoundingSphere &sphere) const override

Compute the bounding radius for the body, in its current pose. Scaling and padding are accounted for.

virtual void computeBoundingCylinder(BoundingCylinder &cylinder) const override

Compute the bounding cylinder for the body, in its current pose. Scaling and padding are accounted for.

virtual void computeBoundingBox(AABB &bbox) const override

Compute the axis-aligned bounding box for the body, in its current pose. Scaling and padding are accounted for.

virtual bool intersectsRay(const Eigen::Vector3d &origin, const Eigen::Vector3d &dir, EigenSTL::vector_Vector3d *intersections = nullptr, unsigned int count = 0) const override

Check if a ray intersects the body, and find the set of intersections, in order, along the ray. A maximum number of intersections can be specified as well. If that number is 0, all intersections are returned. Passing dir as a unit vector will result in faster computation.

virtual BodyPtr cloneAt(const Eigen::Isometry3d &pose, double padding, double scale) const override

Get a clone of this body, but one that is located at the pose pose and has possibly different passing and scaling: padding and scaling. This function is useful to implement thread safety, when bodies need to be moved around.

virtual void updateInternalData() override

This function is called every time a change to the body is made, so that intermediate values stored for efficiency reasons are kept up to date.

Protected Functions

virtual void useDimensions(const shapes::Shape *shape) override

Depending on the shape, this function copies the relevant data to the body.

Protected Attributes

double radius_
Eigen::Vector3d center_
double radiusU_
double radius2_