Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cmath>
- #define PI 3.14159265
- typedef struct Point {
- float x;
- float y;
- } Point;
- int main() {
- float WheelBase, Direction, SteeringAngle, TurnRadius, NewDirection;
- scanf("%f %f %f", &WheelBase, &Direction, &SteeringAngle);
- TurnRadius = WheelBase / (sin(SteeringAngle*PI/180));
- NewDirection = (180 * Direction) / (PI * TurnRadius);
- Point StartingPoint = {0, 0}, EndPoint, Center = {0 + TurnRadius, 0};
- EndPoint.x = Center.x - TurnRadius * (cos((90 + NewDirection)*PI*180));
- EndPoint.y = Center.y - TurnRadius * (atan((90 - NewDirection)*PI*180));
- printf("%0.2f %0.2f %0.2f", EndPoint.x, EndPoint.y, NewDirection);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment