zipnotic
asked on
For Next Loop on compass degrees
Hello,
Trying to build this:
For A = startAzimuth to endAzimuth mod 360 step 10
'Do stuff
Next
But it obviously fails when the start azimuth is less than 360 and end azimuth crosses 360/0. How can I step through compass directions?
A clearer example:
For A = 335 to 25 step 10 mod 360
next A
I believe there was a simple way but I can't find it now.
Thanks!
Trying to build this:
For A = startAzimuth to endAzimuth mod 360 step 10
'Do stuff
Next
But it obviously fails when the start azimuth is less than 360 and end azimuth crosses 360/0. How can I step through compass directions?
A clearer example:
For A = 335 to 25 step 10 mod 360
next A
I believe there was a simple way but I can't find it now.
Thanks!
ASKER
It skipped over the loop with:
For A = 345 to IF(105<360, 105, 105 mod 360) step 10
next a
For A = 345 to IF(105<360, 105, 105 mod 360) step 10
next a
Ok, but 105 is less than 345, so how were you expecting that to work? The initializer, 345 in this case, needs to be smaller than the condition, 105 in your example.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this is intended to always run counterclockwise, right?
If so, I would increase the endAzimuth by 360 until it is same or greater than startAzimuth, using a While loop.
After that, you can use the For loop with confidence.
If so, I would increase the endAzimuth by 360 until it is same or greater than startAzimuth, using a While loop.
After that, you can use the For loop with confidence.
ASKER
Figured it out.
Open in new window