AggregPacking
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Attributes | Static Private Attributes | Friends | List of all members
aggregpacking::Ellipsoid Class Reference

Representation of ellipsoidal aggregate. More...

#include <aggregate.hpp>

Inheritance diagram for aggregpacking::Ellipsoid:
aggregpacking::Aggregate

Public Member Functions

 Ellipsoid ()
 Default constructor.
 
 Ellipsoid (const Vector3 &p)
 Constructor from position. More...
 
 Ellipsoid (double a, double b, double c)
 Constructor from semiaxes. More...
 
 Ellipsoid (const Vector3 &p, double a, double b, double c)
 Constructor from position and semiaxes. More...
 
 Ellipsoid (const Sphere &s)
 Constructor from Sphere. More...
 
double getA ()
 Getter for 1st semiaxis.
 
double getB ()
 Getter for 2nd semiaxis.
 
double getC ()
 Getter for 3rd semiaxis.
 
void setA (double a)
 Setter for 1st semiaxis. More...
 
void setB (double b)
 Setter for 2nd semiaxis. More...
 
void setC (double c)
 Setter for 3rd semiaxis. More...
 
double getRandomAxesRatio ()
 Getter for randomAxesRatio.
 
void setRandomAxesRatio (double v)
 Setter for randomAxesRatio.
 
double computeRelativeDistanceFrom (const Vector3 &p) const
 Computes relative distance between gvien point and given Ellipsoid. Relative distance means in direction pos–p, the value is 1 on surface of the Ellipsoid, in the center is 0, inside Ellipsoid (0,1) and outside Ellipsoid >1. More...
 
virtual bool containsPoint (const Vector3 &p) const
 Ckecks, whether given point is contained by receiver. More...
 
virtual bool containsSphere (const Sphere &s) const
 Ckecks, whether given sphere is contained by receiver. More...
 
virtual double computeDistanceFrom (const Aggregate &aggreg) const
 Computes distance of receiver from given Aggregate. More...
 
virtual double computeVolume () const
 Computes volume of receiver.
 
virtual void fromSize (double s)
 Adjust receiver dimensions accodring to given size. Sets b=0.5*s, a=b*(1+0.5*random), c=b*(1-0.5*random) More...
 
void computeProjectionOnCoordAxis (double &s0, double &w, int axis) const
 Computes parameters of its projction onto coordinate axis (such that the projection is s0+-w) More...
 
virtual double computeMaxCoord (int axis) const
 Computes maximum coordinate along given axis. More...
 
virtual double computeMinCoord (int axis) const
 Computes minimum coordinate along given axis. More...
 
virtual double getSize () const
 Returns size of receiver (what sieve opening it would normally pass), i.e. the middle value from a,b,c.
 
virtual double getMaxSize () const
 Returns maximum size of receiver.
 
Matrix3 computeMatrixB () const
 Computes matrix $\mathbf{B} = \mathbf{R\Sigma}$.
 
Matrix3 computeMatrixBT () const
 Computes matrix $\mathbf{B}^\mathsf{T} = \mathbf{\Sigma R}^\mathsf{T}$.
 
Matrix3 computeMatrixBInversed () const
 Computes matrix $\mathbf{B}^{-1} = \mathbf{\Sigma}^{-1}\mathbf{R}^\mathsf{T}$.
 
Matrix3 computeMatrixBTInversed () const
 Computes matrix $\mathbf{B}^{-\mathsf{T}} = \mathbf{R\Sigma}^{-1}$.
 
Matrix3 computeMatrixSigma () const
 Computes matrix $\mathbf{\Sigma}$, a diagonal matrix with $[\Sigma]_{(ii)}=1/a_i$, where $a_i$ is $i$th smiaxis length.
 
Matrix3 computeMatrixSigmaInversed () const
 Computes matrix $\mathbf{\Sigma}^{-1}$, a diagonal matrix with $[\Sigma]_{(ii)}=a_i$, where $a_i$ is $i$th smiaxis length.
 
Matrix3 computeMatrixSigmaSquare () const
 Computes matrix $\mathbf{\Sigma\Sigma}$.
 
Matrix3 computeMatrixA () const
 Computes matrix $\mathbf{A}=\mathbf{BB}^\mathsf{T}=\mathbf{R\Sigma}^2\mathbf{R}^\mathsf{T}$.
 
Vector3 computeNearestPointFrom (const Vector3 &p) const
 Computes nearest point of receiver to given point. Returns given point if it lies inside the receiver, returns point on its surface otherwise. More...
 
Vector3 computeFarthestPointFrom (const Vector3 &p) const
 Computes farthest point of receiver to given point. Returns point on its surface. The computation is based on Monte-Carlo random sampling. More...
 
double computeEstimatedDistanceFrom (const Ellipsoid &e) const
 Computes estimated distance between receiver and given Ellipsoid. Mainly used as a quick check if two Ellipsoids overlap (return < 0) or not (return > 0) More...
 
virtual const string & getClassName ()
 Returns string representation of Ellipsoid class name.
 
bool operator== (const Aggregate &other) const
 Equality operator. More...
 
bool operator!= (const Aggregate &other) const
 Inequality operator. More...
 
bool isInsideCube (double s) const
 Determines if receiver is entirely inside cube. The cube is in positive octant and has one corner in origin. More...
 
int getNumber ()
 Getter for number.
 
void setNumber (int n)
 Setter for number. More...
 
const Vector3getPos () const
 Getter for position (by reference)
 
Vector3 getPos ()
 Getter for position (by value)
 
void setPos (const Vector3 &p)
 Setter for position. More...
 
void setPos (double x, double y, double z)
 Setter for position (from individual components) More...
 
const QuaterniongetOri () const
 Getter for orientation (by reference)
 
Quaternion getOri ()
 Getter for orientation (by value)
 
void setOri (const Quaternion &q)
 Setter for orientation. More...
 

Static Public Member Functions

static double computeRelativeDistanceFrom (const Vector3 &p, const Matrix3 &bT, const Vector3 &pos)
 Computes relative distance between gvien point and given Ellipsoid. Relative distance means in direction pos–p, the value is 1 on surface of the Ellipsoid, in the center is 0, inside Ellipsoid (0,1) and outside Ellipsoid >1. More...
 
static bool containsPoint (const Vector3 &p, const Matrix3 &bT, const Vector3 &pos)
 Auxiliary structure to test if point lies inside given Ellipsoid. More...
 
static Vector3 computeNearestPointFrom (const Vector3 &p, const Matrix3 &bT, const Vector3 &pos)
 Computes nearest point of Ellipsoid to given point. Returns given point if it lies inside the Ellipsoid, returns point on its surface otherwise. More...
 
static Vector3 computeFarthestPointFrom (const Vector3 &p, const Matrix3 &bT, const Vector3 &pos)
 Computes farthest point of Ellipsoid to given point. Returns point on its surface. The computation is based on Monte-Carlo random sampling. More...
 
static AggregateLoad (istream &is)
 Create and return a new aggregate from given istream. More...
 

Static Public Attributes

static const string className = "Ellipsoid"
 String representation of Ellipsoid class name.
 

Protected Attributes

int number
 Number.
 
Vector3 pos
 Position.
 
Quaternion ori
 Orientation.
 

Private Attributes

double a
 1st semiaxis lengths
 
double b
 2nd semiaxis lengths
 
double c
 3rd semiaxis lengths
 

Static Private Attributes

static double randomAxesRatio = 0.5
 Random axes ratio. Given semiaxis b, a=b*(1+randomAxesRatio*R), c=b*(1-randomAxesRatio*R), R is a random number in range (0,1) More...
 

Friends

ostream & operator<< (ostream &os, const Ellipsoid &o)
 Ellipsoid to ostream shift operator.
 
istream & operator>> (istream &is, Ellipsoid &o)
 Ellipsoid from istream shift operator.
 

Detailed Description

Representation of ellipsoidal aggregate.

Ellipsoidal particles are defined as a set of 3D space points $\mathbf{x}$:

\[\{ \mathbf{x}\ |\ (\mathbf{x}-\mathbf{c})^\mathsf{T}\mathbf{BB}^\mathsf{T}(\mathbf{x}-\mathbf{c}) \le 1 \}\]

$\mathbf{c}$ is the ellipsoid center. $\mathbf{B} = \mathbf{\Sigma}\mathbf{R}^\mathsf{T}$ is a matrix defining the ellipsoid. From other possible definitions (see below) it is used most often. $\mathbf{\Sigma}$ is a diagonal matrix with $[\Sigma]_{(ii)}=1/a_i$ ( $a_i$ is a length of $i$th semiaxis) and $\mathbf{R}$ is an orthogonal rotational matrix (matrix representation of rotation quaternion) with columns equal to rotated coordinate axes.

Alternative definition with $\mathbf{A}=\mathbf{BB}^\mathsf{T}=\mathbf{R\Sigma}^2\mathbf{R}^\mathsf{T}$ is also possible or substituting $\mathbf{y}=\mathbf{B}^\mathsf{T}(\mathbf{x}-\mathbf{c})$ one can define:

\[\{ \mathbf{x}\ |\ ||\mathbf{B}^\mathsf{T}(\mathbf{x}-\mathbf{c})|| \le 1 \}\]

\[\{ \mathbf{x}\ |\ (\mathbf{x}-\mathbf{c})^\mathsf{T}\mathbf{A}^\mathsf{T}(\mathbf{x}-\mathbf{c}) \le 1 \}\]

\[\{ \mathbf{x}\ |\ (\mathbf{x}-\mathbf{c})^\mathsf{T}\mathbf{R\Sigma}^2\mathbf{R}^\mathsf{T}(\mathbf{x}-\mathbf{c}) \le 1 \}\]

\[\{ \mathbf{x}\ |\ \mathbf{x}=\mathbf{c}+\mathbf{B}^{-\mathsf{T}}\mathbf{y}, ||\mathbf{y})|| \le 1 \}\]

Constructor & Destructor Documentation

aggregpacking::Ellipsoid::Ellipsoid ( const Vector3 p)
inline

Constructor from position.

Parameters
pposition
aggregpacking::Ellipsoid::Ellipsoid ( double  a,
double  b,
double  c 
)
inline

Constructor from semiaxes.

Parameters
a1st semiaxis length
b2nd semiaxis length
c3rd semiaxis length
aggregpacking::Ellipsoid::Ellipsoid ( const Vector3 p,
double  a,
double  b,
double  c 
)
inline

Constructor from position and semiaxes.

Parameters
pposition
a1st semiaxis length
b2nd semiaxis length
c3rd semiaxis length
aggregpacking::Ellipsoid::Ellipsoid ( const Sphere s)

Constructor from Sphere.

Parameters
sgiven Sphere object

Member Function Documentation

double aggregpacking::Ellipsoid::computeDistanceFrom ( const Aggregate aggreg) const
virtual

Computes distance of receiver from given Aggregate.

Positive when the aggregates are separate, negative whan they overlap

Parameters
aggregAggregate object to compute distance from
Returns
distance between receiver and given Aggregate

Implements aggregpacking::Aggregate.

double aggregpacking::Ellipsoid::computeEstimatedDistanceFrom ( const Ellipsoid e) const

Computes estimated distance between receiver and given Ellipsoid. Mainly used as a quick check if two Ellipsoids overlap (return < 0) or not (return > 0)

Parameters
egiven Ellipsoid
Vector3 aggregpacking::Ellipsoid::computeFarthestPointFrom ( const Vector3 p,
const Matrix3 bT,
const Vector3 pos 
)
static

Computes farthest point of Ellipsoid to given point. Returns point on its surface. The computation is based on Monte-Carlo random sampling.

Parameters
pgiven point
bT$\mathbf{R}^\mathsf{T}$ matrix of given Ellipsoid
posposition of given Ellipsoid
Vector3 aggregpacking::Ellipsoid::computeFarthestPointFrom ( const Vector3 p) const

Computes farthest point of receiver to given point. Returns point on its surface. The computation is based on Monte-Carlo random sampling.

Parameters
pgiven point
double aggregpacking::Ellipsoid::computeMaxCoord ( int  axis) const
virtual

Computes maximum coordinate along given axis.

Parameters
axis0=x, 1=y, 2=z

Implements aggregpacking::Aggregate.

double aggregpacking::Ellipsoid::computeMinCoord ( int  axis) const
virtual

Computes minimum coordinate along given axis.

Parameters
axis0=x, 1=y, 2=z

Implements aggregpacking::Aggregate.

Vector3 aggregpacking::Ellipsoid::computeNearestPointFrom ( const Vector3 p,
const Matrix3 bT,
const Vector3 pos 
)
static

Computes nearest point of Ellipsoid to given point. Returns given point if it lies inside the Ellipsoid, returns point on its surface otherwise.

Parameters
pgiven point
bT$\mathbf{R}^\mathsf{T}$ matrix of given Ellipsoid
posposition of given Ellipsoid
Vector3 aggregpacking::Ellipsoid::computeNearestPointFrom ( const Vector3 p) const

Computes nearest point of receiver to given point. Returns given point if it lies inside the receiver, returns point on its surface otherwise.

Parameters
pgiven point
void aggregpacking::Ellipsoid::computeProjectionOnCoordAxis ( double &  s0,
double &  w,
int  axis 
) const

Computes parameters of its projction onto coordinate axis (such that the projection is s0+-w)

Parameters
s0projection of receiver's center
wextreme projection length
axisx=0, y=1, z=2
double aggregpacking::Ellipsoid::computeRelativeDistanceFrom ( const Vector3 p,
const Matrix3 bT,
const Vector3 pos 
)
static

Computes relative distance between gvien point and given Ellipsoid. Relative distance means in direction pos–p, the value is 1 on surface of the Ellipsoid, in the center is 0, inside Ellipsoid (0,1) and outside Ellipsoid >1.

Parameters
pgiven point
bT$\mathbf{R}^\mathsf{T}$ matrix of given Ellipsoid
posposition of given Ellipsoid
double aggregpacking::Ellipsoid::computeRelativeDistanceFrom ( const Vector3 p) const

Computes relative distance between gvien point and given Ellipsoid. Relative distance means in direction pos–p, the value is 1 on surface of the Ellipsoid, in the center is 0, inside Ellipsoid (0,1) and outside Ellipsoid >1.

Parameters
pgiven point
bool aggregpacking::Ellipsoid::containsPoint ( const Vector3 p,
const Matrix3 bT,
const Vector3 pos 
)
static

Auxiliary structure to test if point lies inside given Ellipsoid.

Parameters
pgiven point
bT$\mathbf{R}^\mathsf{T}$ matrix of given Ellipsoid
posposition of given Ellipsoid
bool aggregpacking::Ellipsoid::containsPoint ( const Vector3 p) const
virtual

Ckecks, whether given point is contained by receiver.

Parameters
ppoint coordinates
Returns
true if receiver contains given point, false otherwise

Implements aggregpacking::Aggregate.

bool aggregpacking::Ellipsoid::containsSphere ( const Sphere s) const
virtual

Ckecks, whether given sphere is contained by receiver.

Parameters
sgiven sphere object
Returns
true if receiver contains entirely given sphere, false otherwise

Implements aggregpacking::Aggregate.

void aggregpacking::Ellipsoid::fromSize ( double  s)
virtual

Adjust receiver dimensions accodring to given size. Sets b=0.5*s, a=b*(1+0.5*random), c=b*(1-0.5*random)

Parameters
sgiven size

Implements aggregpacking::Aggregate.

bool aggregpacking::Aggregate::isInsideCube ( double  s) const
inherited

Determines if receiver is entirely inside cube. The cube is in positive octant and has one corner in origin.

Parameters
scube size
Returns
true if receiver is entirely contained by a cube with given size, false otherwise
Aggregate * aggregpacking::Aggregate::Load ( istream &  is)
staticinherited

Create and return a new aggregate from given istream.

Parameters
isinput stream
bool aggregpacking::Aggregate::operator!= ( const Aggregate other) const
inlineinherited

Inequality operator.

Intended for Python

Parameters
otherinstance to compare with
bool aggregpacking::Aggregate::operator== ( const Aggregate other) const
inlineinherited

Equality operator.

Intended for Python

Parameters
otherinstance to compare with
void aggregpacking::Ellipsoid::setA ( double  a)
inline

Setter for 1st semiaxis.

a new semiaxis length

void aggregpacking::Ellipsoid::setB ( double  b)
inline

Setter for 2nd semiaxis.

b new semiaxis length

void aggregpacking::Ellipsoid::setC ( double  c)
inline

Setter for 3rd semiaxis.

c new semiaxis length

void aggregpacking::Aggregate::setNumber ( int  n)
inlineinherited

Setter for number.

Parameters
nnew number
void aggregpacking::Aggregate::setOri ( const Quaternion q)
inlineinherited

Setter for orientation.

Parameters
qnew orientation
void aggregpacking::Aggregate::setPos ( const Vector3 p)
inlineinherited

Setter for position.

Parameters
pnew position
void aggregpacking::Aggregate::setPos ( double  x,
double  y,
double  z 
)
inlineinherited

Setter for position (from individual components)

Parameters
xx coordinate
yy coordinate
zz coordinate

Member Data Documentation

double aggregpacking::Ellipsoid::randomAxesRatio = 0.5
staticprivate

Random axes ratio. Given semiaxis b, a=b*(1+randomAxesRatio*R), c=b*(1-randomAxesRatio*R), R is a random number in range (0,1)

default value is 0.5


The documentation for this class was generated from the following files: