The fix proposed by jarvisschultz (#45) is nice but it introduces two new functions in draw_square.cpp, which, IMHO, makes the tutorial code unnecessarily more complicated. Besides, its newly introduced functions use the built-in constant M_PI (3.14159265358979323846264338327950288), rather than PI defined in draw_square.cpp (3.141592) -- the inconsistency would make the tutorial harder to understand, which could potentially trigger hard-to-detect, floating-point-related bugs later on (e.g. when the turtle moves for longer time).
Therefore, I have proposed a simpler, one-line solution that avoids the aforementioned issues. Given that the convention is to have the angle of a turtlesim/Pose to be within [-pi,pi), the fix just added one line in draw_square.cpp that follows this convention.
The fix proposed by jarvisschultz (#45) is nice but it introduces two new functions in
draw_square.cpp
, which, IMHO, makes the tutorial code unnecessarily more complicated. Besides, its newly introduced functions use the built-in constant M_PI (3.14159265358979323846264338327950288), rather than PI defined indraw_square.cpp
(3.141592) -- the inconsistency would make the tutorial harder to understand, which could potentially trigger hard-to-detect, floating-point-related bugs later on (e.g. when the turtle moves for longer time).Therefore, I have proposed a simpler, one-line solution that avoids the aforementioned issues. Given that the convention is to have the angle of a turtlesim/Pose to be within [-pi,pi), the fix just added one line in draw_square.cpp that follows this convention.