The AreaCon Library
1.0
A C++ library for area-constrained partitioning operations
|
#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 |
The base class for defining probability density functions.
AreaCon::Density::Density | ( | ) |
Default Constructor.
AreaCon::Density::Density | ( | const Poly | Region, |
const int | Nx = 0 , |
||
const int | Ny = 0 , |
||
const std::vector< double > | Values = {} |
||
) |
[in] | Region | The (convex) polygonal region of interest. |
[in] | Nx | The number of grid points in the x direction. |
[in] | Ny | The number of grid points in the y direction. |
[in] | Values | 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. |
Calculates the centroid of the polygon Region with respect to the density
[in] | Region | The polygon of interest |
[in] | Volume | The total volume of the region in question |
double AreaCon::Density::CalculateWeightedArea | ( | const Poly | Region | ) | const |
Evaluates the integral of the density over the polygon Region
[in] | Region | The polygon over which the integral is evaluated |
|
private |
A function that checks consistency of parameter sizes.
|
private |
Returns the world coordinates of the grid-point associated with the ii-th entry of the vector Values.
|
private |
Creates the coefficients that are used in numerically evaluating integrals. Results are stored in the associated Int_Params container Integral
|
private |
Pre-calculates and stores the value of relevant integrals over individual grid squares. Results are stored in the associated Int_Params container Integral
|
inline |
Returns the extreme x and y values.
[out] | minx,miny,maxx,maxy |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
double AreaCon::Density::GetVolumeLowerBound | ( | void | ) |
Returns the lower volume bound.
|
private |
Uses interpolation to find the value of the density at the point Test, which is not necessarily a grid point.
[in] | Test | The point of interest. |
Calculates the line integral of the density function over the straight line connecting points p1, p2
[in] | spacing | The spacing between evaluation points |
[in] | p1,p2 | The endpoints of the line in question |
|
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.
[in] | Total | The value of the total integral of the density under the region of interest. |
|
private |
Performs pre-processing steps that are necessary for fast integration.
|
private |
Calculates the value of dx and dy.
|
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.
[in] | Region | The (convex) polygonal region of interest. |
[in] | Nx | The number of grid points in the x direction. |
[in] | Ny | The number of grid points in the y direction. |
[in] | Values | 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. |
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.
[in] | Nx | The number of grid points in the x direction. |
[in] | Ny | The number of grid points in the y direction. |
[in] | Values | 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. |
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.
[in] | VolumeLowerBound | The new bound value; |
|
private |
The grid spacing: dx = maxx-minx/(Nx-1)
|
private |
The grid spacing: dy = maxy-miny/(Ny-1)
|
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.
|
private |
Container that holds parameters relevant to quickly calculating area integrals.
|
private |
The maximum x coordinate of the polygon
|
private |
The maximum y coordinate of the polygon
|
private |
The minimum x coordinate of the polygon
|
private |
The minimum y coordinate of the polygon
|
private |
The number of grid points in the x direction
|
private |
The number of grid points in the y direction
|
private |
The region of interest
|
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.
|
private |
A lower bound on any calculated volume (default = 0). This parameter is used to avoid numerical instability in partition calculations.