BroncBotz3481 / YAGSL-Example

Yet Another General Swerve Library Example Project
Apache License 2.0
58 stars 143 forks source link

Simplify placeInAppropriate0To360Scope #213

Closed GoldenStack closed 4 months ago

GoldenStack commented 4 months ago

placeInAppropriate0To360Scope is a lot more complicated than it needs to be. I simplified it greatly (which also improves its readability) and added a more formal definition to the documentation for clarification.

Aside from the fact that the expected logic is the same as the original function, I performed 100 billion fuzz tests with random angles in a 64-revolution range and my new function does not deviate from the original function except for minuscule differences (less than 10^-12) due to floating point error that arises because the new implementation performs fewer operations, as well as in scenarios with multiple correct outputs (e.g. the original function returns 0 when provided 180.0, 0.0, while mine returns 360).

This was also tested in my school's 2024 competition (well I just graduated from there but you get the point) and it worked perfectly there.

thenetworkgrinch commented 4 months ago

Thank you for this!