Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- int main() {
- double l, r;
- double pd = 0;
- while (scanf("%lf%lf", &l, &r) == 2) {
- if (l < -0.5) break;
- double d = r - l;
- double ctl = d * 2 + (d - pd) * 5; // PD controller
- pd = d;
- double ml = std::max(0.0, std::min(1.0, 1 - ctl));
- double mr = std::max(0.0, std::min(1.0, 1 + ctl));
- printf("%.4lf %.4lf\n", ml, mr);
- fflush(stdout);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement