@@ -289,10 +289,57 @@ func (e *Exporter) GetShips(ids []*Tractor, TractorsByID map[cfg.TractorID]*Trac
289289
290290 ship .MaxAngularSpeedDegS *= Pi180
291291
292- if ship .TimeTo90MaxAngularSpeed > 0.5 {
293- ship .AngularDistanceFrom0ToHalfSec = ship .MaxAngularSpeedDegS * (0.5 / ship .TimeTo90MaxAngularSpeed ) / 2
294- } else {
295- ship .AngularDistanceFrom0ToHalfSec = ship .MaxAngularSpeedDegS * (0.5 - ship .TimeTo90MaxAngularSpeed ) + ship .MaxAngularSpeedDegS * ship .TimeTo90MaxAngularSpeed / 2
292+ {
293+ // original haste's formula
294+ // time += stepSize
295+ // drag = ship.angularDrag[0] * angularVelocity
296+ // netTorque = ship.steeringTorque[0] - drag
297+ // angularAcceleration = netTorque / ship.rotationInertia[0]
298+ // angularVelocity += angularAcceleration * stepSize
299+ // angularDistance += angularVelocity * stepSize
300+ }
301+
302+ { //Iterative computations version
303+
304+ // t := 0.5
305+ // angularVelocity := 0.0
306+ // angularDistance := 0.0
307+
308+ // for i := 0; i <= 10000; i++ {
309+ // stepSize := t / 10000
310+
311+ // drag := AngularDrag * angularVelocity
312+ // netTorque := ship_info.SteeringTorque.X.Get() - drag
313+ // angularAcceleration := netTorque / RoutationIntertia
314+
315+ // angularVelocity += angularAcceleration * stepSize
316+ // angularDistance += angularVelocity * stepSize
317+ // }
318+
319+ // ship.AngularDistanceFrom0ToHalfSec = angularDistance * (180 / math.Pi)
320+
321+ }
322+ {
323+ AngularDistanceClosed := func (t , torque , drag , inertia float64 ) float64 {
324+ k := drag / inertia // drag coefficient
325+ a := torque / inertia // angular acceleration at rest
326+
327+ // Guard: if drag is ~0, simplifies to θ = ½at²
328+ if math .Abs (k ) < 1e-10 {
329+ return 0.5 * a * t * t
330+ }
331+
332+ theta := (a / k )* t - (a / (k * k ))* (1 - math .Exp (- k * t ))
333+ return theta * (180 / math .Pi )
334+ }
335+ t := 0.5
336+ theta := AngularDistanceClosed (
337+ t ,
338+ ship_info .SteeringTorque .X .Get (),
339+ AngularDrag ,
340+ RoutationIntertia ,
341+ )
342+ ship .AngularDistanceFrom0ToHalfSec = theta
296343 }
297344 }
298345 }
0 commit comments