class Shape

Shapes may be defined by either a simple mathematical formula or an interpolated data table.

Subclassed by feasst::Cuboid, feasst::Cylinder, feasst::HalfSpace, feasst::HalfSpaceTilted, feasst::ShapeFile, feasst::ShapeIntersect, feasst::ShapeUnion, feasst::Sphere, feasst::Supertoroid

Public Functions

virtual double nearest_distance(const Position &point) const = 0

Return the distance from the point to the nearest point on the surface. The distance is negative if the point is inside of the shape and positive if it is outside.

virtual bool is_inside(const Position &point) const

Return true if the point is inside of the shape.

virtual bool is_inside(const Position &point, const double diameter) const

Return true if the sphere of given center point and diameter is entirely inside of the shape.

virtual double surface_area() const

Return the surface area (if implemented).

virtual double volume() const

Return the volume (if implemented).

std::vector<Position> grid(const Position &upper, const Position &lower, const int num_in_each_dimen = 1e2)

Return a grid of points inside the surface for visualization. First, construct a grid of points inside a cuboid with furthest corners given by the upper and lower points. Remove points not inside the shape.

param num_in_each_dimen:

use this many points to span each dimension

double integrate(const Position &point, Random *random, argtype args = argtype())

Given a material of arbitrary shape that interacts with an attraction of the form \(U = \sum_i \frac{\epsilon_i}{r^{\alpha_i}}\), where \(r\) is the radial distance from a point and \(\epsilon\) is the interaction energy constant factor, integrate this interaction up to a maximum cutoff distance.

Spherical shells are numerically integrated with values of \(r\) from 0 to max_radius.

An approximate method is obtained to grid the spherical shell with equidistance points. To avoid bias, over many averages, this shell is randomly rotated.


  • invert: consider the inverse shape (default: true)

  • alpha[i]: add the i-th exponential parameter (default: 6). The “[i]” is to be substituted for an integer 0, 1, 2, … If only only alpha, the “[i]” is optional.

  • epsilon[i]: add the i-th constant factor (default: -1). The “[i]” is as described above, and each alpha must have a corresponding epsilon.

  • max_radius: maximum radial extent of spherical shells.

  • num_shells: number of spherical shells.

  • points_per_slice: number of points in each spherical shell.

class ShapedEntity

Subclassed by feasst::ModelHardShape, feasst::ModelLJShape, feasst::ModelSquareWellShape

Public Functions

const std::shared_ptr<Shape> shape() const

Return the shape.