calculate angle???

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 55
Reputation: jerryseinfeld is an unknown quantity at this point 
Solved Threads: 0
jerryseinfeld jerryseinfeld is offline Offline
Junior Poster in Training

calculate angle???

 
0
  #1
May 22nd, 2007
I am using that but I only get some strange words
I get my coordinates from x and y array..... what is the problem???
  1. for(a=1;a<i;a++){
  2. yyy=(y[a-1]- y[a]);
  3. xxx=(x[a-1]- x[a]);
  4. slope[a-1]=yyy/xxx;}
  5. yyy=(y[i-1]- y[0]);
  6. xxx=(x[i-1]- x[0]);
  7. slope[i-1]=yyy/xxx;
  8. for(b=1;b<i;b++){
  9. yyy=(slope[b-1]+slope[b]);
  10. xxx=(1-slope[b-1]*slope[b]);
  11. angle=yyy/xxx;
  12. res=acos(angle) * (180/3.14);
  13. printf("%d. Angle %f\n",b,res);}
  14. yyy=(slope[i-1]+slope[0]);
  15. xxx=(1-slope[i-1]*slope[0]);
  16. lastangle=yyy/xxx;
  17. res=acos(lastangle) * (180/3.14);
  18. printf("%d. Angle %f\n",b,res);
Teach me, Show me, Educate me :)
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: calculate angle???

 
0
  #2
May 23rd, 2007
What are you tryin to do ?
also provide some sample output (also expected output if possible)..
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 45
Reputation: mike.mclennan is an unknown quantity at this point 
Solved Threads: 0
mike.mclennan's Avatar
mike.mclennan mike.mclennan is offline Offline
Light Poster

Re: calculate angle???

 
0
  #3
May 23rd, 2007
  1. for(a=1;a<i;a++)
  2. {
  3. yyy = (y[a-1]- y[a]);
  4. xxx = (x[a-1]- x[a]);
  5. slope[a-1]=yyy/xxx;
  6. }
  7.  
  8. yyy = (y[i-1]- y[0]);
  9. xxx = (x[i-1]- x[0]);
  10. slope[i-1]=yyy/xxx;
  11.  
  12. for(b=1;b<i;b++)
  13. {
  14. yyy = (slope[b-1]+slope[b]);
  15. xxx = (1-slope[b-1]*slope[b]);
  16. angle = yyy/xxx;
  17. res = acos(angle) * (180/3.14);
  18.  
  19. printf("%d. Angle %f\n",b,res);
  20. }
  21.  
  22. yyy = (slope[i-1]+slope[0]);
  23. xxx = (1-slope[i-1]*slope[0]);
  24. lastangle = yyy/xxx;
  25. res = acos(lastangle) * (180/3.14);
  26.  
  27. printf("%d. Angle %f\n",b,res);

yeah now i can read it.
- mike mclennan
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 45
Reputation: mike.mclennan is an unknown quantity at this point 
Solved Threads: 0
mike.mclennan's Avatar
mike.mclennan mike.mclennan is offline Offline
Light Poster

Re: calculate angle???

 
0
  #4
May 23rd, 2007
ok, i am not 100% sure on what you are trying to do but I think you might want to add the second set to the first loop and the 4th set to the second loop. Or you might want to have 4 sets of loops there. I am not sure, but you are looping through the elements of a, but you are only doing the i element once... seems odd. but again I am not sure what you are trying to so. i see slope.... slope is math.
- mike mclennan
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: calculate angle???

 
0
  #5
May 23rd, 2007
Choosing some more meaningful variable names rather than xxx yyy zzz etc would probably tell you a lot.

xxx / yyy is pretty meaningless, but if you had something like apples / oranges, it becomes pretty darn obvious very quickly that it is a completely stupid thing to even try.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC