int multiplier = 4;
int initial_position = 7;
int new_position = multiplier * (initial_position / multiplier);
Note however that if the multiplier does not evenly divide 180, this might not work the way you intended.
multiplier = (int)(1.0/rotation_speed + .5) // rounds
if(initial_position%multiplier > multiplier/2)
new_position = initial_position - initial_position%multiplier + multiplier
else
new_position = initial_position - initial_position%multiplier
You have a big problem however if the multiplier is not a factor of 180 (7,8,11,etc)if abs(current_position) <= multiplier/2
current_position = 0
if current_position <= multiplier/2 or current_position >= 180 - multiplier/2
current_position = 0
Title | # Comments | Views | Activity |
---|---|---|---|
wordappend challenge | 8 | 85 | |
Controlled Assessment GCSE - desperate help needed | 4 | 53 | |
Scripting vs. Programming languages | 25 | 112 | |
C# DataGridView_RowsAdded event not firing | 1 | 39 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
19 Experts available now in Live!