Mar 22, 2024 15:20:38
Does anyone know how to calculate change In direction?
view on scratch
view on legacy ocular
deck26
loading
Certainly possible if I understand the question.
Presumably you're changing direction by less than 180 degrees, at least in the short term. So you can calculate the difference between the old and new direction without worrying about the positive/negative change. Just calculate the difference mod 360 to get a value in the range 0 to 359. That is how far you've turned anti-clockwise but if it's more than 180 you may want to consider it as a clockwise turn by subtracting the value from 360.
Presumably you're changing direction by less than 180 degrees, at least in the short term. So you can calculate the difference between the old and new direction without worrying about the positive/negative change. Just calculate the difference mod 360 to get a value in the range 0 to 359. That is how far you've turned anti-clockwise but if it's more than 180 you may want to consider it as a clockwise turn by subtracting the value from 360.