Gbc
Some generalized barycentric coordinates.
Install / Use
/learn @danston/GbcREADME
Generalized barycentric coordinates (GBC) Ver. 1.0.2
Description
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.
NOTE: This code has been tested only on Mac OS!
Run the code
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!
Simple example
// 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";
NOTE: For more examples see main.cpp!
Visual output
This package allows you to save the coordinate functions in the eps format, for example:
Wachspress coordinates

Mean value coordinates

Metric coordinates

Harmonic coordinates

Bugs
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!
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
