Closed tobbelobb closed 4 years ago
Hello!
I'm just learning OOP and C++, and use this repo for practice.
First, I noticed a copy constructor that seems to do exactly the same as the implicit copy constructor. https://github.com/Misfittech/nano_stepper/blob/5c4fd1bcf080d8b54497ce33e1f1b736a181eeae/firmware/stepper_nano_zero/angle.h#L34
Are there advantages of defining this copy constructor explicitly?
I also noticed an operator overload for subtraction between angles. https://github.com/Misfittech/nano_stepper/blob/5c4fd1bcf080d8b54497ce33e1f1b736a181eeae/firmware/stepper_nano_zero/angle.h#L36
I was curious about what behaviour you wanted to change/control, so I compared the new minus operator with the shorter:
int16_t minus(const Angle &a2) { return (int16_t)(angle - a2.angle); }
... but no pair of input angles gave (a - b) != a.minus(b).
(a - b) != a.minus(b)
Is the explicit wrap condition in the minus-operator code there simply to make the code still work if ANGLE_STEPS ever changes?
ANGLE_STEPS
Thanks for your software and for your time.
Programmer preference. Outside of scope.
Hello!
I'm just learning OOP and C++, and use this repo for practice.
First, I noticed a copy constructor that seems to do exactly the same as the implicit copy constructor. https://github.com/Misfittech/nano_stepper/blob/5c4fd1bcf080d8b54497ce33e1f1b736a181eeae/firmware/stepper_nano_zero/angle.h#L34
Are there advantages of defining this copy constructor explicitly?
I also noticed an operator overload for subtraction between angles. https://github.com/Misfittech/nano_stepper/blob/5c4fd1bcf080d8b54497ce33e1f1b736a181eeae/firmware/stepper_nano_zero/angle.h#L36
I was curious about what behaviour you wanted to change/control, so I compared the new minus operator with the shorter:
... but no pair of input angles gave
(a - b) != a.minus(b)
.Is the explicit wrap condition in the minus-operator code there simply to make the code still work if
ANGLE_STEPS
ever changes?Thanks for your software and for your time.