Last active
March 4, 2016 15:39
-
-
Save afabri/043987203bbc6cf508cc to your computer and use it in GitHub Desktop.
minimal example for SVD bug
This file contains hidden or 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 <iostream> | |
#include <CGAL/leda_real.h> | |
#include <CGAL/CORE_Expr.h> | |
#include <CGAL/Lazy_exact_nt.h> | |
std::ostream& operator<<(std::ostream& os, std::pair<double,double> p) | |
{ | |
os << p.first << ", " << p.second; | |
return os; | |
} | |
template <class FT> | |
void bug() | |
{ | |
FT zero(0); | |
FT ipx(0.3080532378), // ipy(0.1282279698) | |
iqx(0.3080629044), // iqy(0.1282376364) | |
irx(0.3080725711); // iry(0.1282473031) | |
double d1 = 0.1282376364 - 0.1282279698;// iqy - ipy; | |
double d2 = 0.1282473031 - 0.1282376364;// iry - iqy; | |
FT a1(d1); | |
FT a2(d2); | |
FT b1 = ipx - iqx; | |
FT b2 = iqx - irx; | |
FT n1 = a1 * a1 + b1 * b1; | |
FT n2 = a2 * a2 + b2 * b2; | |
FT D1D2 = n1 * n2; | |
FT sqrtD1D2 = CGAL::sqrt(D1D2); | |
FT a1a2b1b2 = a1 * a2 + b1 * b2; | |
FT uz = sqrtD1D2 - a1a2b1b2 ; | |
std::cout << "D1D2 " << CGAL::to_interval(D1D2) << std::endl; | |
//std::cout << "sqrtD1D2 " << CGAL::to_interval(sqrtD1D2) << std::endl; // uncommented it works | |
std::cout << "a1a2b1b2 " << CGAL::to_interval(a1a2b1b2) << std::endl; | |
std::cout << "uz " << CGAL::to_interval(uz) << std::endl; | |
CGAL_assertion(uz!=zero); | |
} | |
int main() | |
{ | |
std::cout.precision(17); | |
std::cout << "\nTesting leda::real\n"; | |
bug<leda::real>(); | |
std::cout << "\nTesting CGAL::Lazy_exact_nt<CORE::Expr>\n"; | |
bug<CGAL::Lazy_exact_nt<CORE::Expr> >(); | |
std::cout << "\nTesting CORE::Expr\n"; | |
bug<CORE::Expr >(); | |
return 0; | |
} |
This file contains hidden or 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 <iostream> | |
#include <CGAL/Simple_cartesian.h> | |
#include <CGAL/Segment_Delaunay_graph_2.h> | |
#include <CGAL/Segment_Delaunay_graph_filtered_traits_2.h> | |
#include <CGAL/CORE_Expr.h> | |
typedef CGAL::Simple_cartesian<double> Rep; | |
typedef CGAL::Field_with_sqrt_tag MTag; | |
typedef CGAL::Field_with_sqrt_tag EMTag; | |
typedef CGAL::Simple_cartesian<CORE::Expr> ERep; | |
typedef CGAL::Segment_Delaunay_graph_filtered_traits_2<Rep, | |
MTag, | |
ERep, | |
EMTag> Gt; | |
typedef CGAL::Segment_Delaunay_graph_2<Gt> SDG_2; | |
int main() | |
{ | |
SDG_2 svd; | |
Gt::Point_2 p(0.3080532378, 0.1282279698), | |
q(0.3080629044, 0.1282376364), | |
r(0.3080725711, 0.1282473031), | |
s(0, 0); | |
SDG_2::Vertex_handle vp = svd.insert(p); | |
SDG_2::Vertex_handle vq = svd.insert(q); | |
svd.insert(vp,vq); | |
SDG_2::Vertex_handle vr = svd.insert(r); | |
svd.insert(vq,vr); | |
svd.insert(s); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For s we can take any point and it crashes.