Created
March 4, 2016 07:58
-
-
Save sloriot/dd7e28f54b1c10ae9d44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CGAL/leda_real.h> | |
#include <CGAL/CORE_Expr.h> | |
#include <CGAL/Lazy_exact_nt.h> | |
#include <CGAL/Simple_cartesian.h> | |
#include <iostream> | |
template <class Segment_2, class FT> | |
void compute_supporting_line(const Segment_2& s, | |
FT& a, FT& b, FT& c) | |
{ | |
a = s.source().y() - s.target().y(); | |
b = s.target().x() - s.source().x(); | |
c = s.source().x() * s.target().y() - s.target().x() * s.source().y(); | |
} | |
template <class FT> | |
void bug() | |
{ | |
typedef CGAL::Simple_cartesian<FT> K; | |
typedef typename K::Point_2 Point_2; | |
typedef typename K::Segment_2 Segment_2; | |
Point_2 ip(0.3080532378, 0.1282279698), | |
iq(0.3080629044, 0.1282376364), | |
ir(0.3080725711, 0.1282473031); | |
Segment_2 sq(ip,iq); | |
Segment_2 sr(iq,ir); | |
Point_2 pp=ip; | |
FT a1, b1, c1, a2, b2, c2; | |
compute_supporting_line(sq, a1, b1, c1); | |
compute_supporting_line(sr, a2, b2, c2); | |
FT c1_ = a1 * pp.x() + b1 * pp.y() + c1; | |
FT c2_ = a2 * pp.x() + b2 * pp.y() + c2; | |
c1_ = FT(0); | |
FT n1 = CGAL::square(a1) + CGAL::square(b1); | |
FT n2 = CGAL::square(a2) + CGAL::square(b2); | |
FT D1D2 = n1 * n2; | |
FT uz = -a1 * a2 - b1 * b2 + CGAL::sqrt(D1D2); | |
// the homogeneous coordinates of the Voronoi vertex are: | |
// (J + pp.x() * uz, uy = I + pp.y() * uz, uz) | |
if (uz==0) | |
{ | |
std::cout << std::setprecision(17); | |
std::cout << "CGAL::sqrt(D1D2)==a1 * a2 + b1 * b2 : " << (CGAL::sqrt(D1D2)==a1 * a2 + b1 * b2) << "\n"; | |
std::cout << "a1*b2==b1*a2 : " << (a1*b2==b1*a2) << "\n"; | |
std::cout << "D1D2==CGAL::square(a1 * a2 + b1 * b2) : " << (D1D2==CGAL::square(a1 * a2 + b1 * b2)) << "\n"; | |
std::cout << "CGAL::square(CGAL::sqrt(D1D2))==CGAL::square(a1 * a2 + b1 * b2) : " << (CGAL::square(CGAL::sqrt(D1D2))==CGAL::square(a1 * a2 + b1 * b2)) << "\n"; | |
} | |
CGAL_assertion(uz!=0); | |
} | |
int main() | |
{ | |
std::cout << "testing leda::real\n"; | |
bug<leda::real>(); | |
std::cout << "testing CGAL::Lazy_exact_nt<CORE::Expr>\n"; | |
bug<CGAL::Lazy_exact_nt<CORE::Expr> >(); | |
std::cout << "testing CORE::Expr\n"; | |
bug<CORE::Expr >(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment