Giter Club home page Giter Club logo

gbc_fork's Introduction

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:

  1. Install macports
  2. Open main.cpp and edit the path to the folder with images on the line 142
  3. 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
Wachspress coordinates

Mean value coordinates
Mean value coordinates

Metric coordinates
Metric coordinates

Harmonic 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!

gbc_fork's People

Contributors

danston avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.