Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

complete rotation

Status
Not open for further replies.

jscorpion

Programmer
Nov 17, 2000
40
US
I am graphing data points on a x an y graph. As the angle changes I take a reading of another device. I take as many readings as possible within a 360 degree rotation. How can I in vb code tell when I have made one rotation. You can not use > or < than since I am comparing radians. Is there some sample code someone could post to show me a probably obvious solution.

Thank You!

jscorpion
 
sorry, I am comparing degrees not radians. My mistake
 
Do until degrees > 360
..
..
Loop Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
degrees never gets > than 360 it returns back to 0 which is causing the delima. I am reading an external device which is giving me the information in degrees, once a complete circle is done it returns back to zero. This is why > and < than comparisons are not working.

Thank you for your response.

 
If it's always going in the same direction then degrees will increase to 359 then go back to 0

If my understanding is correct then

Dim nearlydone as Boolean
Dim done as Boolean
Done = False
Nearlydone = False
Do until Done
...
...

If degrees > 300 then
nearlydone = true
end if
If nearlydone=true and degrees < 1 then
nearlydone = false
done = true
loop

This should take you round once Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Yes, I had thought of doing it that way, but I did not know if there was a better way to compare degrees in vb. I guess that is the route I will go. Thank you for your help.

jscorpion
 
I think there may be simpler approach. Since your moving in a clockwise direction - degrees should always be increasing, except at the completion of a rotation, then whenever the current value is less than the previous value, you would have completed a rotation.

if (current_degree < previous_degree) then
Rotation Complete
End If
previous_degree = current_degree Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thank you CajunCenturion for your response. That does seem to be a better way with less code. One of my orginal problems was that I may not be starting at zero everytime which would mess that formula up, but I have decided to code it to subtract the value back to start at zero so this should work great. Thank you again!

jscorpion
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top