944,045 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 4785
  • C++ RSS
May 22nd, 2007
0

calculate angle???

Expand Post »
I am using that but I only get some strange words
I get my coordinates from x and y array..... what is the problem???
C++ Syntax (Toggle Plain Text)
  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);
Similar Threads
Reputation Points: 8
Solved Threads: 0
Junior Poster in Training
jerryseinfeld is offline Offline
55 posts
since Apr 2007
May 23rd, 2007
0

Re: calculate angle???

What are you tryin to do ?
also provide some sample output (also expected output if possible)..
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
May 23rd, 2007
0

Re: calculate angle???

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 39
Solved Threads: 0
Light Poster
mike.mclennan is offline Offline
45 posts
since May 2007
May 23rd, 2007
0

Re: calculate angle???

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.
Reputation Points: 39
Solved Threads: 0
Light Poster
mike.mclennan is offline Offline
45 posts
since May 2007
May 23rd, 2007
0

Re: calculate angle???

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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Heap block at 003D2CA0 modified at 003D2CB3 past requested size of b
Next Thread in C++ Forum Timeline: Linker -help needed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC