YorKnEz

Untitled

Oct 29th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cmath>
  3.  
  4. #define PI 3.14159265
  5.  
  6. typedef struct Point {
  7. float x;
  8. float y;
  9. } Point;
  10.  
  11. int main() {
  12. float WheelBase, Direction, SteeringAngle, TurnRadius, NewDirection;
  13.  
  14. scanf("%f %f %f", &WheelBase, &Direction, &SteeringAngle);
  15.  
  16. TurnRadius = WheelBase / (sin(SteeringAngle*PI/180));
  17.  
  18. NewDirection = (180 * Direction) / (PI * TurnRadius);
  19.  
  20. Point StartingPoint = {0, 0}, EndPoint, Center = {0 + TurnRadius, 0};
  21.  
  22. EndPoint.x = Center.x - TurnRadius * (cos((90 + NewDirection)*PI*180));
  23. EndPoint.y = Center.y - TurnRadius * (atan((90 - NewDirection)*PI*180));
  24.  
  25. printf("%0.2f %0.2f %0.2f", EndPoint.x, EndPoint.y, NewDirection);
  26.  
  27. return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment