Calculating points distance (application freezes)

Hello people...!

Got a rather odd question but it is really stooping my development.

I am calculating a distance between two points for two separate center points of a bounding box.
My application works fine after I put the code to calculate the distance between points of the first center.

When I add the code to my application to calculate the distance between points of the second center point my application freezes completely.

There are no compiler errors neither run time errors the application just stops (freezes) after a second or 2 and stays like this forever.....



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    vector<Point> Rightarm;
    	vector<Point> Leftarm;
    
    	vector<Point> Left_Arm_xy;
    	vector<Point> Right_Arm_xy;
    
    	vector<double> Left_Point_distance;
    	vector<double> Right_Point_distance;	
    
    Left_Arm_xy.push_back(cv::Point(center.x,center.y));
    
    	Right_Arm_xy.push_back(cv::Point(center1.x,center1.y));
    
    
    	double Pt1; 
    	double Pt2; 
    	for(vector<Point>::iterator iter_a = Left_Arm_xy.begin()+1; iter_a != Left_Arm_xy.end(); ++iter_a)
    	{
    		
    		Pt1 = pow((double) iter_a->x - (iter_a -1)->x,2);
    		Pt2 = pow((double) iter_a->y - (iter_a -1)->y,2);
    
    			double result_a;
    			result_a  = (Pt1 + Pt2);
    		
    			Left_Point_distance.push_back(sqrt(result_a));
    			
    	}
    
    
    
    	//----------------------------------------------------------------------------->
    
    	double Pt3; 
    	double Pt4; 
    	for(vector<Point>::iterator iter_b = Right_Arm_xy.begin()+1; iter_b != Right_Arm_xy.end(); iter_b)
    	{
    		
    		Pt3 = pow((double) iter_b->x - (iter_b -1)->x,2);
    		Pt4 = pow((double) iter_b->y - (iter_b -1)->y,2);
    
    			double result_b;
    			result_b  = (Pt3 + Pt4);
    		
    			Right_Point_distance.push_back(sqrt(result_b));
    
    	}

Really have no idea of why this could be happening....could anyone possibly suggest an issue that exists withing the code....?
Regards
line 36 is causing your infinite loop

should be:
for(vector<Point>::iterator iter_b = Right_Arm_xy.begin()+1; iter_b != Right_Arm_xy.end(); ++iter_b)
goshhhhhhhhh HEHE thank you so much Not to sure how i didn't spot this but but once again THANKS. regards
Topic archived. No new replies allowed.