Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Use the following input file for the program
- $ cat input | ./test
- -731.881 -1269.91 19.4598
- -400.371 -1269.91 28.8654
- -418.045 -1040.68 21.817
- -502.333 -786.248 12.1586
- -669.351 -897.239 10.59
- -731.881 -938.793 10.0027
- -731.881 -1269.91 41.8424
- -731.881 -809.848 26.3075
- -440.816 -745.367 12.7363
- -731.881 -928.878 11.2564
- -377.473 -939.518 1.55859
- */
- #include <iostream>
- #include <cassert>
- #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
- #include <CGAL/Polytope_distance_d.h>
- #include <CGAL/Polytope_distance_d_traits_3.h>
- typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
- typedef Kernel::Point_3 Point;
- typedef CGAL::Polytope_distance_d_traits_3<Kernel> Traits;
- typedef CGAL::Polytope_distance_d<Traits> Polytope_distance;
- int main()
- {
- Point P[11];
- Point *Q = P+10;
- for(int i = 0; i < 11; ++i) {
- std::cin >> P[i];
- std::cout << P[i] << std::endl;
- }
- Polytope_distance pd(P, P+10, Q, Q+1); // Doesn't work
- //Polytope_distance pd(Q, Q+1, P, P+10); // Works
- assert (pd.is_valid());
- // get squared distance
- std::cout << "Squared distance: " <<
- CGAL::to_double (pd.squared_distance_numerator()) /
- CGAL::to_double (pd.squared_distance_denominator()) << std::endl;
- // get points that realize the distance
- Polytope_distance::Coordinate_iterator coord_it;
- std::cout << "p:"; // homogeneous point from first polyhedron
- for (coord_it = pd.realizing_point_p_coordinates_begin();
- coord_it != pd.realizing_point_p_coordinates_end();
- ++coord_it)
- std::cout << " " << *coord_it;
- std::cout << std::endl;
- std::cout << "q:"; // homogeneous point from second polyhedron
- for (coord_it = pd.realizing_point_q_coordinates_begin();
- coord_it != pd.realizing_point_q_coordinates_end();
- ++coord_it)
- std::cout << " " << *coord_it;
- std::cout << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment