float GetFollowerIDMAcc(IDMInfo myIDMInfo, DriverBehavior followingDriver) { if (myIDMInfo.followingS <= 0) { return(-Algebra.Infinity); } float desiredDist = followingDriver.s0 + Mathf.Max(0f, myIDMInfo.followingV * followingDriver.T + myIDMInfo.followingV * myIDMInfo.followingDeltaV / (2 * Mathf.Sqrt(followingDriver.a * followingDriver.b))); return(followingDriver.a * (1f - Mathf.Pow(myIDMInfo.followingV / followingDriver.v0, followingDriver.delta) - Mathf.Pow(desiredDist / myIDMInfo.followingS, 2))); }
float GetFollowerIDMAccWithoutMe(IDMInfo myIDMInfo, DriverBehavior followingDriver) { IDMInfo partialInfoForFollower = new IDMInfo { laneNo = myIDMInfo.laneNo, leadingS = myIDMInfo.followingS + myIDMInfo.leadingS, leadingV = myIDMInfo.leadingV, myV = myIDMInfo.followingV }; return(GetIDMAcc(partialInfoForFollower, followingDriver)); }
float GetIDMAcc(IDMInfo iDMInfo, DriverBehavior driver) { if (iDMInfo.leadingS <= 0) { //if would collide return(-Algebra.Infinity); } float desiredDist = driver.s0 + Mathf.Max(0f, iDMInfo.myV * driver.T + iDMInfo.myV * iDMInfo.deltaV / (2 * Mathf.Sqrt(driver.a * driver.b))); return(driver.a * (1f - Mathf.Pow(iDMInfo.myV / driver.v0, driver.delta) - Mathf.Pow(desiredDist / iDMInfo.leadingS, 2))); }