/* * Box.hpp * * Created on: Jun 30, 2010 * Author: crueger */ #ifndef BOX_HPP_ #define BOX_HPP_ class RealSpaceMatrix; class Vector; class Shape; class Plane; #include #include #include "LinearAlgebra/VectorSet.hpp" /** * A simple class that can be used to store periodic Boxes * in the form of a parallelepiped. * * Stores a matrix that can be used to translate from periodic * [0,1) space as well as the inverse that is needed to * translate back to that space. */ class Box { public: typedef enum{ Wrap, Bounce, Ignore } BoundaryCondition_t; typedef vector Conditions_t; Box(); Box(const Box&); virtual ~Box(); /** * Get the matrix describing the form of the parallelepiped */ const RealSpaceMatrix &getM() const; /** * Get the inverse of the matrix M (see above). */ const RealSpaceMatrix &getMinv() const; /** * Set the form of the parallelepiped. */ void setM(RealSpaceMatrix); Box &operator=(const Box&); Box &operator=(const RealSpaceMatrix&); /** * Translate a point from [0,1) to the boxed space. */ Vector translateIn(const Vector &point) const; /** * Translate a point from the boxed space to the [0,1) space. */ Vector translateOut(const Vector &point) const; /** * Wrap a point so that it will lie within the space defined by the box. */ Vector WrapPeriodically(const Vector &point) const; /** * Checks whether a given vector is inside the box. */ bool isInside(const Vector &point) const; /** * Produce corresponding points in several adjacent boxes. * * n specifies the number of times the point is expanded. * Carefull, needs O(n^3) time and produces as many vectors. */ VECTORSET(std::list) explode(const Vector &point,int n) const; VECTORSET(std::list) explode(const Vector &point) const; /** * Calculate the distance of two points in the periodic space * defined by this box */ double periodicDistanceSquared(const Vector &point1,const Vector &point2) const; /** * Calculate the distance of two points in the periodic space * defined by this box */ double periodicDistance(const Vector &point1,const Vector &point2) const; Shape getShape() const; const Conditions_t getConditions(); void setCondition(int,BoundaryCondition_t); const vector > getBoundingPlanes(); void setCuboid(const Vector&); private: Conditions_t conditions; RealSpaceMatrix *M; //!< Defines the layout of the box RealSpaceMatrix *Minv; //!< Inverse of M to avoid recomputation }; #endif /* BOX_HPP_ */