From 61f5a26e61809935de97d28cdc34bda16d3b21a4 Mon Sep 17 00:00:00 2001 From: Daniil Pankevich <69798762+nilpunch@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:20:48 +0300 Subject: [PATCH] Fix turning angle calculation That one math function break turning radius of the vehicle. Here is a simple fix. The math is following: turnRadius = wheelBase / Sin(steeringAngle) turnAngle = arcLength / turnRadius So, turnAngle = arcLength / wheelBase * Sin(steeringAngle) --- Assets/Scripts/Pathfinding/Hybrid A star/HybridAStar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/Pathfinding/Hybrid A star/HybridAStar.cs b/Assets/Scripts/Pathfinding/Hybrid A star/HybridAStar.cs index 0d8c8a2..82ee2e9 100644 --- a/Assets/Scripts/Pathfinding/Hybrid A star/HybridAStar.cs +++ b/Assets/Scripts/Pathfinding/Hybrid A star/HybridAStar.cs @@ -454,7 +454,7 @@ private static List GetChildrenToNode(Node currentNode, Map map, Cell[,] c float alpha = steeringAngles[j]; //Turning angle - float beta = (driveDistance / carData.WheelBase) * Mathf.Tan(alpha); + float beta = (driveDistance / carData.WheelBase) * Mathf.Sin(alpha); //Simulate the car driving forward by using a mathematical car model Vector3 newRearWheelPos = VehicleSimulationModels.CalculateNewPosition(heading, beta, driveDistance, currentNode.rearWheelPos);