Skip to content

Commit

Permalink
slightly more cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <[email protected]>
  • Loading branch information
lamont-granquist committed Sep 5, 2020
1 parent ce777b1 commit 173e482
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions MechJeb2/AttitudeControllers/HybridController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ public void UpdatePhi()
double yaw = ea[1] *UtilMath.Deg2Rad;
double roll = ea[2] *UtilMath.Deg2Rad;

// law of cosines for the "distance" of the miss in radians
phiTotal = Math.Acos( MuUtils.Clamp( Math.Cos(pitch)*Math.Cos(yaw), -1, 1 ) );

// this is the initial direction of the great circle route of the requested transform
// (pitch is latitude, yaw is longitude, and we are "navigating" from 0,0)
Vector3d temp = new Vector3d(Math.Sin(pitch), Math.Cos(pitch) * Math.Sin(yaw), 0);
temp = temp.normalized;

// law of cosines for the "distance" of the miss in radians
phiTotal = Math.Acos( MuUtils.Clamp( Math.Cos(pitch)*Math.Cos(yaw), -1, 1 ) );
temp = temp.normalized * phiTotal;

// we assemble phi in the pitch, roll, yaw basis that vessel.MOI uses (right handed basis)
Vector3d phi = new Vector3d(
MuUtils.ClampRadiansPi(-temp[0]*phiTotal), // pitch distance around the geodesic
MuUtils.ClampRadiansPi(-temp[0]), // pitch distance around the geodesic
MuUtils.ClampRadiansPi(-roll),
MuUtils.ClampRadiansPi(temp[1]*phiTotal) // yaw distance around the geodesic
MuUtils.ClampRadiansPi(temp[1]) // yaw distance around the geodesic
);

phi.Scale(ac.AxisState);
Expand Down

0 comments on commit 173e482

Please sign in to comment.