#include <CGAL/Simple_cartesian.h>
#include <CGAL/Barycentric_coordinates_2/Triangle_coordinates_2.h>
typedef std::vector<Scalar> Scalar_vector;
using std::cout; using std::endl; using std::string;
int main()
{
const Point first_vertex(0.0f, 0.0f);
const Point second_vertex(2.0f, 0.5f);
const Point third_vertex(1.0f, 2.0f);
Scalar_vector coordinates;
Triangle_coordinates triangle_coordinates(first_vertex, second_vertex, third_vertex);
triangle_coordinates.print_information();
const int number_of_query_points = 18;
const Point query_points[] = { Point(0.5f , 0.5f ), Point(1.0f, 0.5f ), Point(1.0f , 0.75f), Point(1.0f , 1.0f),
Point(1.0f , 1.25f), Point(1.0f, 1.5f ), Point(0.75f, 1.0f ), Point(1.25f, 1.0f), Point(1.5f, 0.75f),
Point(1.0f , 0.25f), Point(0.5f, 1.0f ), Point(1.5f , 1.25f), Point(1.0f , 2.0f), Point(2.0f, 0.5f ),
Point(0.25f, 1.0f ), Point(0.5f, 1.75f), Point(1.5f , 1.75f), Point(1.75f, 1.5f)
};
coordinates.reserve(number_of_query_points * 3);
cout << endl << "Computed triangle coordinates: " << endl << endl;
for(int i = 0; i < number_of_query_points; ++i) {
triangle_coordinates(query_points[i], std::inserter(coordinates, coordinates.end()));
cout << "Point " << i + 1 << ": ";
for(int j = 0; j < 3; ++j)
cout << "coordinate " << j + 1 << " = " << coordinates[i * 3 + j] << "; ";
cout << endl << endl;
}
return EXIT_SUCCESS;
}