1 #ifndef CBALGOSHORTESTDISTNONENDPOINT_CXX 2 #define CBALGOSHORTESTDISTNONENDPOINT_CXX 23 const ::cluster::ClusterParamsAlg &cluster2)
28 if (
_debug) { std::cout <<
"Num of Hits below threshold..." << std::endl; }
32 double w_start1 = cluster1.GetParams().start_point.w;
33 double t_start1 = cluster1.GetParams().start_point.t;
34 double w_end1 = cluster1.GetParams().end_point.w;
35 double t_end1 = cluster1.GetParams().end_point.t;
37 double w_start2 = cluster2.GetParams().start_point.w;
38 double t_start2 = cluster2.GetParams().start_point.t;
39 double w_end2 = cluster2.GetParams().end_point.w;
40 double t_end2 = cluster2.GetParams().end_point.t;
43 std::cout <<
"Start point Cluster 1: (" << w_start1 <<
", " << t_start1 <<
")" << std::endl;
44 std::cout <<
"End point Cluster 2: (" << w_end1 <<
", " << t_end1 <<
")" << std::endl;
45 std::cout <<
"Start point Cluster 1: (" << w_start2 <<
", " << t_start2 <<
")" << std::endl;
46 std::cout <<
"End point Cluster 2: (" << w_end2 <<
", " << t_end2 <<
")" << std::endl;
68 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
69 shortest_distance2_tmp : shortest_distance2;
76 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
77 shortest_distance2_tmp : shortest_distance2;
84 shortest_distance2 = (shortest_distance2_tmp < shortest_distance2) ?
85 shortest_distance2_tmp : shortest_distance2;
91 if(compatible) std::cout<<Form(
" Compatible in distance (%g).\n",shortest_distance2);
92 else std::cout<<Form(
" NOT compatible in distance (%g).\n",shortest_distance2);
102 double start_x,
double start_y,
103 double end_x,
double end_y )
const {
111 double distance_squared = 999999;
114 double length_squared = pow((end_x - start_x), 2) + pow((end_y - start_y), 2);
119 std::cout << std::endl;
120 std::cout << Form(
" Provided very short line segment: (%g,%g) => (%g,%g)",
121 start_x,start_y,end_x,end_y) << std::endl;
122 std::cout <<
" Likely this means one of two clusters have start & end point identical." << std::endl;
123 std::cout <<
" Check the cluster output!" << std::endl;
124 std::cout << std::endl;
125 std::cout << Form(
" At this time, the algorithm uses a point (%g,%g)",start_x,start_y) << std::endl;
126 std::cout <<
" to represent this cluster's location." << std::endl;
127 std::cout << std::endl;
130 return (pow((point_x - start_x),2) + pow((point_y - start_y),2));
134 double t = ( (point_x - start_x)*(end_x - start_x) + (point_y - start_y)*(end_y - start_y) ) / length_squared;
143 if(t>0.1 && t < 0.9) distance_squared = pow((point_x - (start_x + t*(end_x - start_x))), 2) + pow((point_y - (start_y + t*(end_y - start_y))),2);
146 return distance_squared;
Class def header for a class CBAlgoShortestDistNonEndpoint.