The AreaCon Library  1.0
A C++ library for area-constrained partitioning operations
 All Classes Namespaces Files Functions Variables Pages
AreaCon::Density Class Reference

#include <areacon.h>

Public Member Functions

void SetNewRegion (const Poly Region, const int Nx=0, const int Ny=0, const std::vector< double > Values={})
 
void SetParameters (const int Nx, const int Ny, const std::vector< double > Values)
 
int GetNx (void) const
 
int GetNy (void) const
 
Poly GetRegion (void) const
 
std::vector< bool > GetGridInRegion (void) const
 
Int_Params GetIntegral (void) const
 
void GetExtrema (double &minx, double &miny, double &maxx, double &maxy) const
 
double LineIntegral (double spacing, const Point &p1, const Point &p2) const
 
double CalculateWeightedArea (const Poly Region) const
 
Point CalculateCentroid (const Poly Region, const double &Volume) const
 
void SetVolumeLowerBound (const double VolumeLowerBound)
 
double GetVolumeLowerBound (void)
 
 Density ()
 
 Density (const Poly Region, const int Nx=0, const int Ny=0, const std::vector< double > Values={})
 

Private Member Functions

void CheckParameterSizes (void)
 
void SetExtrema (void)
 
void Setdxy (void)
 
void PreprocessIntegral (void)
 
void CreateIntegralCoefficients (void)
 
double CreateIntegralVector (void)
 
void NormalizeIntegralVector (const double &Total)
 
double InterpolateValue (const Point &Test) const
 
Point ConvertIndextoWorld (const int ii) const
 

Private Attributes

Poly Region
 
int Nx
 
int Ny
 
double dx
 
double dy
 
double minx
 
double miny
 
double maxx
 
double maxy
 
double Volume_Lower_Bound
 
std::vector< double > Values
 
std::vector< bool > GridInRegion
 
Int_Params Integral
 

Detailed Description

The base class for defining probability density functions.

Author
Jeffrey R. Peters

Constructor & Destructor Documentation

AreaCon::Density::Density ( )

Default Constructor.

AreaCon::Density::Density ( const Poly  Region,
const int  Nx = 0,
const int  Ny = 0,
const std::vector< double >  Values = {} 
)
Parameters
[in]RegionThe (convex) polygonal region of interest.
[in]NxThe number of grid points in the x direction.
[in]NyThe number of grid points in the y direction.
[in]ValuesA vector containing the value of the density function at the grid-point locations (the value at the (i,j)-th grid point is stored in the (Ny*i+j)-th entry of Values.

Member Function Documentation

Point AreaCon::Density::CalculateCentroid ( const Poly  Region,
const double &  Volume 
) const

Calculates the centroid of the polygon Region with respect to the density

Parameters
[in]RegionThe polygon of interest
[in]VolumeThe total volume of the region in question
Returns
The location of the centroid
double AreaCon::Density::CalculateWeightedArea ( const Poly  Region) const

Evaluates the integral of the density over the polygon Region

Parameters
[in]RegionThe polygon over which the integral is evaluated
Returns
The weighted area of the region
void AreaCon::Density::CheckParameterSizes ( void  )
private

A function that checks consistency of parameter sizes.

Point AreaCon::Density::ConvertIndextoWorld ( const int  ii) const
private

Returns the world coordinates of the grid-point associated with the ii-th entry of the vector Values.

Returns
The world coordinates of the associated grid point.
void AreaCon::Density::CreateIntegralCoefficients ( void  )
private

Creates the coefficients that are used in numerically evaluating integrals. Results are stored in the associated Int_Params container Integral

double AreaCon::Density::CreateIntegralVector ( void  )
private

Pre-calculates and stores the value of relevant integrals over individual grid squares. Results are stored in the associated Int_Params container Integral

Returns
The value of the total integral of the density under the region of interest.
void AreaCon::Density::GetExtrema ( double &  minx,
double &  miny,
double &  maxx,
double &  maxy 
) const
inline

Returns the extreme x and y values.

Parameters
[out]minx,miny,maxx,maxy
std::vector<bool> AreaCon::Density::GetGridInRegion ( void  ) const
inline
Returns
GridInRegion
Int_Params AreaCon::Density::GetIntegral ( void  ) const
inline
Returns
Integral
int AreaCon::Density::GetNx ( void  ) const
inline
Returns
Nx
int AreaCon::Density::GetNy ( void  ) const
inline
Returns
Ny
Poly AreaCon::Density::GetRegion ( void  ) const
inline
Returns
Region
double AreaCon::Density::GetVolumeLowerBound ( void  )

Returns the lower volume bound.

Returns
Volume_Lower_Bound;
double AreaCon::Density::InterpolateValue ( const Point Test) const
private

Uses interpolation to find the value of the density at the point Test, which is not necessarily a grid point.

Parameters
[in]TestThe point of interest.
Returns
The value of the density function at Test
double AreaCon::Density::LineIntegral ( double  spacing,
const Point p1,
const Point p2 
) const

Calculates the line integral of the density function over the straight line connecting points p1, p2

Parameters
[in]spacingThe spacing between evaluation points
[in]p1,p2The endpoints of the line in question
Returns
The value of the line integral
void AreaCon::Density::NormalizeIntegralVector ( const double &  Total)
private

Makes sure that the values stored in the integral vector are normalized so that their sum is equal to 1 over the region of interest.

Parameters
[in]TotalThe value of the total integral of the density under the region of interest.
void AreaCon::Density::PreprocessIntegral ( void  )
private

Performs pre-processing steps that are necessary for fast integration.

void AreaCon::Density::Setdxy ( void  )
private

Calculates the value of dx and dy.

void AreaCon::Density::SetExtrema ( void  )
private

Finds and sets the extrema for the polygon Region, i.e., sets minx, maxx, miny, maxy.

void AreaCon::Density::SetNewRegion ( const Poly  Region,
const int  Nx = 0,
const int  Ny = 0,
const std::vector< double >  Values = {} 
)

Function used to set a new polygonal region of interest.

Parameters
[in]RegionThe (convex) polygonal region of interest.
[in]NxThe number of grid points in the x direction.
[in]NyThe number of grid points in the y direction.
[in]ValuesA vector containing the value of the density function at the grid-point locations (the value at the (i,j)-th grid point is stored in the (Ny*i+j)-th entry of Values.
void AreaCon::Density::SetParameters ( const int  Nx,
const int  Ny,
const std::vector< double >  Values 
)

Function used to re-set the values of the grid-parameters.

Parameters
[in]NxThe number of grid points in the x direction.
[in]NyThe number of grid points in the y direction.
[in]ValuesA vector containing the value of the density function at the grid-point locations (the value at the (i,j)-th grid point is stored in the (Ny*i+j)-th entry of Values.
void AreaCon::Density::SetVolumeLowerBound ( const double  VolumeLowerBound)

Sets the lower volume bound (default = 0). This bound is used to avoid numerical instability in partition calculations.

Parameters
[in]VolumeLowerBoundThe new bound value;

Member Data Documentation

double AreaCon::Density::dx
private

The grid spacing: dx = maxx-minx/(Nx-1)

double AreaCon::Density::dy
private

The grid spacing: dy = maxy-miny/(Ny-1)

std::vector<bool> AreaCon::Density::GridInRegion
private

A vector whose entries indicate whether or not grid points lie within Region. If the (i,j)-th grid point lies within the polygonal region of interest, then the (Ny*i+j)-th entry of GridInRegion is true, otherwise it is false.

Int_Params AreaCon::Density::Integral
private

Container that holds parameters relevant to quickly calculating area integrals.

double AreaCon::Density::maxx
private

The maximum x coordinate of the polygon

double AreaCon::Density::maxy
private

The maximum y coordinate of the polygon

double AreaCon::Density::minx
private

The minimum x coordinate of the polygon

double AreaCon::Density::miny
private

The minimum y coordinate of the polygon

int AreaCon::Density::Nx
private

The number of grid points in the x direction

int AreaCon::Density::Ny
private

The number of grid points in the y direction

Poly AreaCon::Density::Region
private

The region of interest

std::vector<double> AreaCon::Density::Values
private

A vector containing the value of the density function at the grid-point locations (the value at the (i,j)-th grid point is stored in the (Ny*i+j)-th entry of Values.

double AreaCon::Density::Volume_Lower_Bound
private

A lower bound on any calculated volume (default = 0). This parameter is used to avoid numerical instability in partition calculations.


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