Implementation of some generalized barycentric coordinates in R2.
This package includes:
1. Pointwise coordinates:
A. Coordinates for polygons:
- Bilinear coordinates
- Wachspress coordinates
- Discrete harmonic coordinates
- Mean value coordinates
- Positive mean value coordinates
- Cubic mean value coordinates
- Three-point coordinates
- Metric coordinates
- Poisson coordinates
- Gordon-Wixom coordinates
- Positive Gordon-Wixom coordinates
- Maximum entropy coordinates
B. Coordinates for scattered points:
- Affine coordinates
- Sibson coordinates
- Laplace coordinates
2. Mesh-based coordinates:
A. Coordinates for polygons:
- Harmonic coordinates
- Local barycentric coordinates
I tried to keep the code as stand alone as possible, but many classes still have quite a few dependencies. However, all these dependencies are included in the package and do not require any special treatment like building or compiling. At the beginning of each file I also indicate which dependencies the corresponding class has.
In order to run the code, do the following:
- Install macports
- Open main.cpp and edit the path to the folder with images on the line 142
- Open terminal and type the following:
sudo port install cmake
cd path_to_your_folder_with_gbc_package/2d/
mkdir bin
cd bin
cmake -DCMAKE_BUILD_TYPE=Debug ..
make
./gbc
For the release version use instead:
cmake -DCMAKE_BUILD_TYPE=Release ..
NOTE: If the output result shows FAILED for some tests, it is ok. It happens because the corresponding coordinate functions do not satisfy some theoretical properties of generalized barycentric coordinates!
// Polygon.
std::vector<VertexR2> poly(4);
poly[0] = VertexR2(0.1, 0.1);
poly[1] = VertexR2(1.0, 0.0);
poly[2] = VertexR2(0.9, 0.9);
poly[3] = VertexR2(0.2, 1.0);
// Evaluation point.
VertexR2 centre(0.5, 0.5);
// Storage for the computed barycentric coordinates.
std::vector<double> b;
// Compute mean value coordinates.
MeanValueR2 mvc(poly);
mvc.compute(centre, b);
// Output the resulting coordinates.
std::cout << "\nMean value coordinates: ";
for (size_t i = 0; i < b.size(); ++i) std::cout << b[i] << " ";
std::cout << "\n\n";
This package allows you to save the coordinate functions in the eps format, for example:
Please note that some parts of this code are not optimized and may bug. I only tested it for the specific cases that I used during the last years of my Ph.D. That is why, if you find any bugs, please report them to me, and I will try to fix them as soon as possible!