ahwa Posted May 30, 2015 Share Posted May 30, 2015 def firstOrderInterceptTime(shotSpeed, targetRelativePosition, targetRelativeVelocity): velocitySquared = targetRelativeVelocity.lengthSquared if velocitySquared < 0.001: return 0.0 a = velocitySquared - shotSpeed * shotSpeed if abs(a) < 0.001: t = -targetRelativePosition.lengthSquared / (2.0 * targetRelativeVelocity.dot(targetRelativePosition)) return max(t, 0.0) b = 2.0 * targetRelativeVelocity.dot(targetRelativePosition) c = targetRelativePosition.lengthSquared determinant = b * b - 4.0 * a * c if determinant > 0.0: t1 = (-b + math.sqrt(determinant)) / (2.0 * a) t2 = (-b - math.sqrt(determinant)) / (2.0 * a) if t1 > 0.0: if t2 > 0.0: return min(t1, t2) else: return t1 else: return max(t2, 0.0) else: if determinant < 0.0: return 0.0 return max(-b / (2.0 * a), 0.0) Apply mechanically and modify to WOT SpeedInfo = BigWorld.target.filter.speedInfo.value speed = SpeedInfo[0] fwdSpeedLimit, bckwdSpeedLimit = BigWorld.target.typeDescriptor.physics['speedLimits'] MAX_SPEED_MULTIPLIER = 1.5 fwdSpeedLimit *= MAX_SPEED_MULTIPLIER bckwdSpeedLimit *= MAX_SPEED_MULTIPLIER if speed > fwdSpeedLimit: speed = fwdSpeedLimit elif speed < -bckwdSpeedLimit: speed = -bckwdSpeedLimit TargetSpeed = abs(round(speed, 3)) try: Yaw = BigWorld.target.yaw except: Yaw = 0.0 Dist = (BigWorld.player().getOwnVehiclePosition() - TargetPosition).length ShotSpeed = BigWorld.player().vehicleTypeDescriptor.shot['speed'] ShotTime = FirstOrderInterceptTime(ShotSpeed, Dist, TargetSpeed, Yaw) def FirstOrderInterceptTime(ShotSpeed, Dist, Speed, Yaw): Y = Dist if Speed < 0.001: return 0.0 Yaw = Yaw + math.pi a = Speed - ShotSpeed * ShotSpeed if abs(a) < 0.001: t = -Y / (2.0 * Y * math.cos(Yaw)) return max(t, 0.0) b = 2.0 * Y * math.cos(Yaw) c = Y ** 2 determinant = b * b - 4.0 * a * c if determinant > 0.0: t1 = (-b + math.sqrt(determinant)) / (2.0 * a) t2 = (-b - math.sqrt(determinant)) / (2.0 * a) if t1 > 0.0: if t2 > 0.0: return min(t1, t2) else: return t1 else: return max(t2, 0.0) else: if determinant < 0.0: return 0.0 return max(-b / (2.0 * a), 0.0) I do this wrong???? How do I Apply mechanically and modify 1 1 @ Quote Link to comment Short link Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.