15#include "image_processing.h"
16#include "simpleTreeVec.h"
20template<
typename T,
typename P>
22 return Point_2d(p1[0] - p2[0], p1[1] - p2[1]);
25double crossD(P &O,P &A,P &B){
26 return (A[0] - O[0]) * (B[1] - O[1]) - (A[1] - O[1]) * (B[0] - O[0]);
34 if(curve.size() <=3)
return 0;
36 size_t N = curve.size(),count = 0;
39 curve.push_back(curve[0]);
41 for(
size_t i=0;i<N-2;++i){
42 for(
size_t j=i+2;j<N;++j){
43 if(Utilities::Geometry::intersect(curve[i].x,curve[i+1].x,curve[j].x,curve[j+1].x)){
47 std::swap(curve[k] , curve[l]);
66std::vector<Point_2d>
TighterHull(
const std::vector<Point_2d> &v);
69std::vector<Point_2d>
TightestHull(
const std::vector<Point_2d> &v);
173std::vector<Point_2d>
RandomInPoly(std::vector<Point_2d> &pp,
203 ,std::vector<std::vector<P> > &points
204 ,std::vector<bool> &hits_edge
205 ,
bool add_to_vector=
false
206 ,
bool outer_only=
false
209 size_t n = bitmap.size();
213 std::cerr <<
"Wrong sizes in Utilities::find_boundaries." << std::endl;
214 throw std::invalid_argument(
"invalid size");
217 std::vector<bool> not_used(n,
true);
220 for(
size_t i=0 ; i<nx ; ++i) bitmap[i]=
false;
221 size_t j = nx*(ny-1);
222 for(
size_t i=0 ; i<nx ; ++i) bitmap[i + j]=
false;
223 for(
size_t i=0 ; i<ny ; ++i) bitmap[i*nx]=
false;
225 for(
size_t i=0 ; i<ny ; ++i) bitmap[j + i*nx]=
false;
227 std::list<std::list<Point_2d>> contours;
234 long kfirst_in_bound = -1;
239 for( k = kfirst_in_bound + 1 ; k < n - nx ; ++k){
242 if(bitmap[k] ) type +=1;
243 if(bitmap[k+1]) type += 10;
244 if(bitmap[k + nx]) type += 100;
245 if(bitmap[k + nx + 1]) type += 1000;
260 contours.resize(contours.size() + 1);
261 std::list<Point_2d> &contour = contours.back();
262 hits_edge.push_back(
false);
270 while(k != kfirst_in_bound || n_edge==0){
273 std::cerr <<
"Too many points in Utilities::find_boundaries()." << std::endl;
274 std::cerr <<
"kfirst_in_bound " << kfirst_in_bound << std::endl;
275 std::cerr <<
" contour is output to boundary_error_file.csv and bitmap_error_file.csv" << std::endl;
277 std::ofstream file(
"bitmap_error_file.csv");
278 file <<
"in,x,y" << std::endl;
279 for(
size_t i=0 ; i<n ; ++i){
280 file << bitmap[i] <<
"," << i%nx <<
"," << i/nx << std::endl;
285 std::ofstream file(
"boundary_error_file.csv");
286 file <<
"contour,x,y" << std::endl;
288 for(
auto &v : contours){
290 file << i <<
"," << p[0] <<
"," << p[1] << std::endl;
295 throw std::runtime_error(
"caught in loop.");
298 if(k%nx == 0 || k%nx == nx-2) hits_edge.back() =
true;
299 if(k/nx == 0 || k/nx == ny-2) hits_edge.back() =
true;
306 if(bitmap[k]) type +=1;
307 if(bitmap[k+1]) type += 10;
308 if(bitmap[k + nx]) type += 100;
309 if(bitmap[k + nx + 1]) type += 1000;
311 if(type == 0 || type == 1111){
312 throw std::runtime_error(
"off edge!!");
313 }
else if(type == 1 || type == 1110){
316 contour.push_back(
Point_2d( k%nx + 0.5
329 }
else if(type == 10 || type == 1101){
332 contour.push_back(
Point_2d( k%nx + 0.5
338 contour.push_back(
Point_2d( k%nx + 1
345 }
else if(type == 100 || type == 1011){
348 contour.push_back(
Point_2d( k%nx + 0.5
361 }
else if(type == 1000 || type == 111){
364 contour.push_back(
Point_2d( k%nx + 1
370 contour.push_back(
Point_2d( k%nx + 0.5
377 }
else if(type == 11 || type == 1100){
380 contour.push_back(
Point_2d( k%nx + 1
392 }
else if(type == 1010 || type == 101){
395 contour.push_back(
Point_2d( k%nx + 0.5
400 contour.push_back(
Point_2d( k%nx + 0.5
407 }
else if(type == 1001){
410 contour.push_back(
Point_2d( k%nx + 0.5
415 }
else if(face_in==1){
421 }
else if(face_in==2){
422 contour.push_back(
Point_2d( k%nx + 0.5
428 contour.push_back(
Point_2d( k%nx + 1
435 }
else if(type == 110){
438 contour.push_back(
Point_2d( k%nx + 0.5
443 }
else if(face_in==1){
444 contour.push_back(
Point_2d( k%nx + 1
449 }
else if(face_in==2){
450 contour.push_back(
Point_2d( k%nx + 0.5
472 if(outer_only)
break;
478 points.resize(contours.size());
480 offset = points.size();
481 points.resize(points.size() + contours.size());
486 for(
auto &c: contours){
487 points[offset+i].resize(c.size());
490 points[offset+i][j] = p;
500 ,std::vector<std::vector<long> > &indexes
501 ,std::vector<bool> &hits_edge
502 ,
bool add_to_vector=
false
507 ,
const std::vector<Point_2d> &x);
525 std::vector<T> hull(2*n);
528 std::sort(P.begin(), P.end(),
530 if(p1[0]==p2[0]) return p1[1] < p2[1];
531 return p1[0] < p2[0];});
535 for (
size_t i = 0; i < n; i++) {
536 while (k >= 2 && crossD(hull[k-2], hull[k-1], P[i]) <= 0){
543 for (
long i = n-2, t = k+1; i >= 0; i--) {
544 while (k >= t && crossD(hull[k-2], hull[k-1], P[i]) <= 0){
561void convex_hull(
const std::vector<T> &P,std::vector<size_t> &hull)
569 for(
size_t &d : hull) d = i++;
578 std::vector<size_t> sort_index(P.size());
581 for(
size_t &a : sort_index) a = i++;
583 std::sort(sort_index.begin(), sort_index.end(),
584 [&P](
size_t i1,
size_t i2){
585 if(P[i1][0]==P[i2][0]) return P[i1][1] < P[i2][1];
586 return P[i1][0] < P[i2][0];});
590 for (
size_t i = 0; i < n; i++) {
591 while (k >= 2 && crossD(P[hull[k-2]], P[hull[k-1]], P[sort_index[i]]) <= 0){
594 hull[k++] = sort_index[i];
598 for (
long i = n-2, t = k+1; i >= 0; i--) {
599 while (k >= t && crossD(P[hull[k-2]], P[hull[k-1]],P[sort_index[i]]) <= 0){
603 hull[k++] = sort_index[i];
614 Edge(
size_t i,
double l):length(l),index(i){};
635 ,std::vector<T> &hull_out,
double scale)
645 if(init_points.size() == hull.size())
return;
647 std::list<Edge> edges;
648 std::list<T> leftovers;
649 hull.push_back(hull[0]);
654 for(
int i=0;i<hull.size()-1;++i){
655 tmp = (subtract(hull[i],hull[i+1])).length();
656 if(tmp > scale) edges.emplace_back(i,tmp);
659 if(edges.size() == 0)
return;
662 PosType cent[] ={0.5,0.5};
667 map.drawPoints(init_points,0.01,1.0);
668 map.drawCurve(hull,2);
674 edges.sort([](
const Edge &p1,
const Edge &p2){
return p1.length > p2.length;});
675 assert(edges.front().length >= edges.back().length);
681 std::vector<size_t> index(hull.size());
683 for(
size_t &ind: index) ind = i++;
684 std::sort(index.begin(),index.end(),
685 [&hull](
size_t p1,
size_t p2){
686 if(hull[p1][0] == hull[p2][0]) return hull[p1][1] < hull[p2][1];
687 return hull[p1][0] < hull[p2][0];});
691 for(
auto pit = init_points.begin(); pit != init_points.end() ; ++pit){
693 if((hull[index[j]][0] == (*pit)[0])*(hull[index[j]][1] == (*pit)[1])){
696 leftovers.push_back(*pit);
700 assert(hull.size() + leftovers.size() == init_points.size());
701 hull.push_back(hull[0]);
704 typename std::list<T>::iterator p,nextpoint;
707 double minarea,area,co1;
712 while(edges.front().length > scale ){
714 if(leftovers.size() == 0)
break;
718 i = edges.front().index;
720 for(p = leftovers.begin() ; p != leftovers.end() ; ++p){
722 v1 = subtract(*p,hull[i]);
724 if( edges.front().length > v1.
length()){
726 vo = subtract(hull[i+1], hull[i]);
732 if( co1 > 0 && (area > 0)*(area < minarea) ){
740 if(minarea == HUGE_VAL){
748 leftovers.erase(nextpoint);
749 hull.insert(hull.begin() + i + 1,tmp);
752 Edge new1 = edges.front();
754 new1.length = (subtract(hull[i],hull[i+1])).length();
755 Edge new2(i+1,(subtract(hull[i+1],hull[i+2])).length());
757 for(
auto &p : edges)
if(p.index > i) ++(p.index);
759 auto p = edges.begin();
760 if(new1.length > scale){
761 for(p = edges.begin() ; p != edges.end() ; ++p){
762 if((*p).length < new1.length){
763 edges.insert(p,new1);
767 if(p==edges.end()) edges.push_back(new1);
769 if(new2.length > scale){
770 for(p = edges.begin(); p != edges.end() ; ++p){
771 if((*p).length < new2.length){
772 edges.insert(p,new2);
776 if(p==edges.end()) edges.push_back(new2);
781 PosType cent[] ={0.5,0.5};
786 map.drawPoints(init_points,0.03,1.0);
787 map.drawCurve(hull,2);
797 std::swap(hull,hull_out);
803std::vector<T> concave2(std::vector<T> &init_points,
double scale)
813 if(init_points.size() == hull.size())
return hull;
815 std::list<Edge> edges;
816 std::list<T> leftovers;
817 hull.push_back(hull[0]);
822 for(
int i=0;i<hull.size()-1;++i){
823 tmp = (subtract(hull[i],hull[i+1])).length();
824 if(tmp > scale) edges.emplace_back(i,tmp);
827 if(edges.size() == 0)
return hull;
830 PosType cent[] ={0.5,0.5};
833 map.drawgrid(10,0.5);
835 map.drawPoints(init_points,0.01,1.0);
836 map.drawCurve(hull,2);
838 map.printFITS(
"!test_concave.fits");
842 edges.sort([](
const Edge &p1,
const Edge &p2){
return p1.length > p2.length;});
843 assert(edges.front().length >= edges.back().length);
849 std::vector<size_t> index(hull.size());
851 for(
size_t &ind: index) ind = i++;
852 std::sort(index.begin(),index.end(),
853 [&hull](
size_t p1,
size_t p2){
854 if(hull[p1][0] == hull[p2][0]) return hull[p1][1] < hull[p2][1];
855 return hull[p1][0] < hull[p2][0];});
859 for(
auto pit = init_points.begin(); pit != init_points.end() ; ++pit){
861 if((hull[index[j]][0] == (*pit)[0])*(hull[index[j]][1] == (*pit)[1])){
864 leftovers.push_back(*pit);
868 assert(hull.size() + leftovers.size() == init_points.size());
869 hull.push_back(hull[0]);
872 typename std::list<T>::iterator p,nextpoint;
875 double minarea,area,co1;
879 while(edges.front().length > scale ){
881 if(leftovers.size() == 0)
break;
885 i = edges.front().index;
887 for(p = leftovers.begin() ; p != leftovers.end() ; ++p){
889 v1 = subtract(*p,hull[i]);
891 if( edges.front().length > v1.
length()){
893 vo = subtract(hull[i+1], hull[i]);
899 if( co1 > 0 && (area > 0)*(area < minarea) ){
907 if(minarea == HUGE_VAL){
915 leftovers.erase(nextpoint);
916 hull.insert(hull.begin() + i + 1,tmp);
919 Edge new1 = edges.front();
921 new1.length = (subtract(hull[i],hull[i+1])).length();
922 Edge new2(i+1,(subtract(hull[i+1],hull[i+2])).length());
924 for(
auto &p : edges)
if(p.index > i) ++(p.index);
926 auto p = edges.begin();
927 if(new1.length > scale){
928 for(p = edges.begin() ; p != edges.end() ; ++p){
929 if((*p).length < new1.length){
930 edges.insert(p,new1);
934 if(p==edges.end()) edges.push_back(new1);
936 if(new2.length > scale){
937 for(p = edges.begin(); p != edges.end() ; ++p){
938 if((*p).length < new2.length){
939 edges.insert(p,new2);
943 if(p==edges.end()) edges.push_back(new2);
948 PosType cent[] ={0.5,0.5};
951 map.drawgrid(10,0.5);
953 map.drawPoints(init_points,0.03,1.0);
954 map.drawCurve(hull,2);
956 map.printFITS(
"!test_concave.fits");
968template <
typename Ptype>
969double distance_to_segment(
const Ptype &P
975 double s = (P-S1)*D / D.length_sqr();
977 return (P-S1).length();
979 return (P-S2).length();
981 return (S1 + D*s - P).length();
984template <
typename Ptype>
985double distance_to_segment(
const Ptype &P
988 ,Ptype &closest_point
992 double s = (P-S1)*D / D.length_sqr();
995 return (P-S1).length();
998 return (P-S2).length();
1000 closest_point = S1 + D*s;
1001 return (S1 + D*s - P).length();
1005template <
typename Ptype>
1006bool segments_cross(
const Ptype &a1,
const Ptype &a2
1007 ,
const Ptype &b1,
const Ptype &b2){
1012 double tmp = (db^da);
1013 if(tmp==0)
return false;
1015 double B = (da^d1) / tmp;
1016 if( (B>1) || (B<0))
return false;
1018 if( (B>1) || (B<0))
return false;
1022template <
typename Ptype>
1023bool inCurve(
const Ptype &x,
const std::vector<Ptype> &H){
1025 size_t n = H.size();
1026 if(n <=2)
return false;
1030 for(
size_t i=0 ; i<n-1 ; ++i){
1033 if(x[1] == H[i][1]){
1034 B = (x[0]-H[i][0])/dH[0];
1035 if( B>=0 && B<=1 )
return true;
1040 if( A > 1 || A <= 0)
continue;
1054template <
typename Ptype>
1055bool inhull(PosType x[],
const std::vector<Ptype> &H){
1057 size_t n = H.size();
1058 if(n <=2)
return false;
1062 for(
size_t i=0 ; i<n-1 ; ++i){
1065 if(x[1] == H[i][1]){
1066 B = (x[0]-H[i][0])/dH[0];
1067 if( B>=0 && B<=1 )
return true;
1070 dD[0] = x[0]-H[i][0];
1071 dD[1] = x[1]-H[i][1];
1073 if( A > 1 || A <= 0)
continue;
1088inline bool inhull<Point *>(PosType x[],
const std::vector<Point *> &H){
1090 size_t n = H.size();
1091 if(n <=2)
return false;
1095 for(
size_t i=0 ; i<n-1 ; ++i){
1098 if(x[1] == H[i]->x[1]){
1099 B = (x[0]-H[i]->x[0])/dH[0];
1100 if( B>=0 && B<=1 )
return true;
1103 dD[0] = x[0]-H[i]->x[0];
1104 dD[1] = x[1]-H[i]->x[1];
1106 if( A > 1 || A <= 0)
continue;
1124 size_t n = H.size();
1125 if(n <=2)
return false;
1129 for(
size_t i=0 ; i<n-1 ; ++i){
1130 dH = H[i+1].x-H[i].x;
1132 if(x[1] == H[i].x[1]){
1133 B = (x[0]-H[i].x[0])/dH[0];
1134 if( B>=0 && B<=1 )
return true;
1137 dD[0] = x[0]-H[i].x[0];
1138 dD[1] = x[1]-H[i].x[1];
1140 if( A > 1 || A <= 0)
continue;
1155inline bool inhull<PosType *>(PosType x[],
const std::vector<PosType *> &H){
1157 size_t n = H.size();
1158 if(n <=2)
return false;
1162 for(
size_t i=0 ; i<n-1 ; ++i){
1163 dH[0] = H[i+1][0]-H[i][0];
1164 dH[1] = H[i+1][1]-H[i][1];
1166 if(x[1] == H[i][1]){
1167 B = (x[0]-H[i][0])/dH[0];
1168 if( B>=0 && B<=1 )
return true;
1171 dD[0] = x[0]-H[i][0];
1172 dD[1] = x[1]-H[i][1];
1174 if( A > 1 || A <= 0)
continue;
1198template <
typename Ptype>
1199std::vector<Ptype>
concaveK(std::vector<Ptype> &points,
int &k,
bool check=
true)
1202 if(points.size() <= 3){
1208 size_t npoints = points.size();
1225 std::vector<Ptype> hull;
1227 double xmin = points[0][0];
1228 size_t first_point_index = 0;
1229 for(
size_t i=0 ; i<npoints ; ++i){
1230 if(points[i][0] < xmin){
1231 xmin = points[i][0];
1232 first_point_index = i;
1236 Ptype firstpoint = points[first_point_index];
1238 std::vector<size_t> remaining_index;
1239 bool segmented =
true;
1246 if(k>=points.size()){
1251 hull.push_back(firstpoint);
1254 std::vector<double> radii;
1255 std::vector<size_t> neighbors;
1256 Ptype hull_end = hull.back();
1259 Ptype last_point = Ptype(hull[0][0],hull[0][1]-1);
1265 std::vector<double> thetas;
1266 std::vector<int> sorted_index(k);
1268 while((hull[0] != hull.back() && found) || hull.size()==1 ){
1272 long Nneighbors = neighbors.size();
1273 thetas.resize(Nneighbors);
1274 sorted_index.resize(Nneighbors);
1276 v1 = hull_end - last_point;
1278 for(
int i=0; i<Nneighbors ; ++i){
1279 v2 = points[neighbors[i]] - hull_end;
1280 double cross = v1^v2,dot = (v1*v2);
1281 if(cross == 0 && dot <= 0) thetas[i] = -PI;
1282 else thetas[i] = atan2( cross , dot );
1283 sorted_index[i] = i;
1286 std::sort(sorted_index.begin(),sorted_index.end()
1287 ,[&thetas](
int i,
int j){return thetas[i] > thetas[j];} );
1290 bool intersect =
true;
1291 while(intersect && trial < Nneighbors){
1293 new_index = neighbors[ sorted_index[trial] ];
1294 new_point = points[ new_index ];
1296 if(hull.size() <= 3) intersect =
false;
1299 for(
long i = hull.size() - 2 ; i > 1 ; --i){
1300 intersect = segments_cross(hull[i],hull[i-1]
1301 ,hull.back(),new_point);
1308 if(new_index == first_point_index && !intersect){
1311 hull.push_back(new_point);
1312 for(
size_t i : neighbors){
1313 if(i != new_index && !inCurve(points[i],hull)){
1343 hull.push_back(new_point);
1344 last_point = hull_end;
1345 hull_end = hull.back();
1347 tree.
pop(new_index);
1369 for(
auto i : remaining_index){
1370 if(!inCurve(points[i],hull)){
1400template <
typename Ptype>
1402 std::vector<Ptype> points(200);
1403 RandomNumbers_NR ran(2312);
1405 for(Ptype &p : points){
1411 for(
int i=0 ; i< points.size()/4 ; ++i){
1417 for(
int i=points.size()/4 ; i< 2*points.size()/4 ; ++i){
1423 for(
int i=2*points.size()/4 ; i< 3*points.size()/4 ; ++i){
1429 for(
int i=3*points.size()/4 ; i< points.size() ; ++i){
1450 std::vector<Ptype> hull =
concaveK(points,k);
1454 map.drawCurve(hull,1);
1455 map.drawPoints(points,0,2);
1456 map.printFITS(
"!concavek_test.fits");
1457 std::cout <<
"Test plot : concavek_test.fits" << std::endl;
1480std::vector<Point_2d>
envelope(
const std::vector<Point_2d> &v
1481 ,
const std::vector<Point_2d> &w);
1488std::vector<Point_2d>
envelope2(
const std::vector<Point_2d> &v
1489 ,
const std::vector<Point_2d> &w);
1499 const std::vector<Point_2d> &v
Image structure that can be manipulated and exported to/from fits files.
Definition pixelmap.h:42
void printFITS(std::string filename, bool Xflip=false, bool verbose=false)
Output the pixel map as a fits file.
Definition pixelmap.cpp:1309
void drawgrid(int N, PosType value)
draw a grid on the image that divides the each demension into N cells
Definition pixelmap.cpp:1705
A tree for doing quick searches in multidimensional space. A pointer to an array of objects type T is...
Definition simpleTreeVec.h:22
void pop(IndexType index_of_point)
pop this point out of the tree
Definition simpleTreeVec.h:61
std::vector< IndexType > get_index() const
returns the index numbers of the remaining points which are less than the original if pop() was used.
Definition simpleTreeVec.h:105
void NearestNeighbors(D *ray, int Nneighbors, std::vector< D > &radii, std::vector< IndexType > &neighbors)
Finds the nearest N neighbors and puts their index numbers in an array, also returns the distance to ...
Definition simpleTreeVec.h:464
This is a class for generating random numbers. It simplifies and fool proofs initialization and allow...
Definition utilities_slsim.h:1059
Definition utilities.h:39
size_t RemoveIntersections(std::vector< T > &curve)
removes the intersections of the curve
Definition concave_hull.h:32
Point_2d RandomInPoly(std::vector< Point_2d > &pp, Utilities::RandomNumbers_NR &ran)
return a point within a polygon that doesn't need to be convex
Definition curve_routines.cpp:3748
void find_boundaries(std::vector< bool > &bitmap, long nx, std::vector< std::vector< P > > &points, std::vector< bool > &hits_edge, bool add_to_vector=false, bool outer_only=false)
finds ordered boundaries to regions where bitmap == true
Definition concave_hull.h:201
double interior_mass(const std::vector< Point_2d > &alpha, const std::vector< Point_2d > &x)
this returns area within the curve x average kappa iwithin the curve
Definition curve_routines.cpp:2165
std::vector< Point_2d > envelope(const std::vector< Point_2d > &v, const std::vector< Point_2d > &w)
Find a curve that is made up of segments from v and w that surrounds them and does not self intersect...
Definition curve_routines.cpp:3213
void concave(std::vector< T > &init_points, std::vector< T > &hull_out, double scale)
Creates the concave hull of a group of 2 dimensional points by the shrink-wrap algorithm.
Definition concave_hull.h:634
std::vector< Point_2d > TighterHull(const std::vector< Point_2d > &v)
Definition curve_routines.cpp:3355
bool inhull< RAY >(PosType x[], const std::vector< RAY > &H)
finds in x is within the curve discribed by the H[].x points ie image points
Definition concave_hull.h:1122
std::vector< Point_2d > envelope2(const std::vector< Point_2d > &v, const std::vector< Point_2d > &w)
Find a curve that is made up of segments from v and w that surrounds them and does not self intersect...
Definition curve_routines.cpp:3154
std::vector< std::vector< Point_2d > > thicken_poly(const std::vector< Point_2d > &v, double R)
return the boundaries of the region that is within R of the curve v
Definition curve_routines.cpp:3053
Point_2d RandomInTriangle(const Point_2d &x1, const Point_2d &x2, const Point_2d &x3, Utilities::RandomNumbers_NR &ran)
returns random point within a trinagle
Definition curve_routines.cpp:3681
std::vector< Ptype > concaveK(std::vector< Ptype > &points, int &k, bool check=true)
Definition concave_hull.h:1199
std::vector< T > convex_hull(const std::vector< T > &PP)
Returns a vector of points on the convex hull in counter-clockwise order.
Definition concave_hull.h:514
std::vector< Point_2d > TightestHull(const std::vector< Point_2d > &v)
Finds a concave envolope for an arbitrary closed curve. This is done by gridding and then finding poi...
Definition curve_routines.cpp:3598
Point_2d RandomInConvexPoly(const std::vector< Point_2d > &pp, Utilities::RandomNumbers_NR &ran)
return a point within a convex polygon
Definition curve_routines.cpp:3695
void find_islands(std::vector< bool > &bitmap, long nx, std::vector< std::vector< long > > &indexes, std::vector< bool > &hits_edge, bool add_to_vector=false)
find the indexes of areas with bitmap[]=true broken up into diconnected islands
Definition curve_routines.cpp:2757
bool circleOverlapsCurve(const Point_2d &x, double r, const std::vector< Point_2d > &v)
Returns true if there is any overlap between a curve and a circle. This includea cases where one comp...
Definition curve_routines.cpp:3042
Point_2d line_intersection(const Point_2d &v1, const Point_2d &v2, const Point_2d &w1, const Point_2d &w2)
return the interesetion point of line defined by v1,v2 and w1,w2
Definition curve_routines.cpp:3015
Point_2d RandomNearPoly(std::vector< Point_2d > &pp, double R, Utilities::RandomNumbers_NR &ran)
return a point within distance R of a polygon, i.e. the center of a cicle that intersects the interio...
Definition curve_routines.cpp:3818
bool circleIntersetsCurve(const Point_2d &x, double r, const std::vector< Point_2d > &v)
returns true if a circle of radius r around the point x intersects with the curve v....
Definition curve_routines.cpp:3023
Class for representing points or vectors in 2 dimensions. Not that the dereferencing operator is over...
Definition point.h:48
PosType length() const
length
Definition point.h:134