Skip to content

Commit

Permalink
Move otherwise unused static methods from Misc to KethaneDetectorAnim…
Browse files Browse the repository at this point in the history
…ator
  • Loading branch information
Majiir committed Sep 4, 2014
1 parent 3df9e5d commit f624355
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
18 changes: 0 additions & 18 deletions Plugin/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@ public static double GetTrueAltitude(Vessel vessel)
return altitudeTrue;
}

public static double NormalizeAngle(double a)
{
a = a % 360;
if (a < 0)
a += 360;
return a;
}

public static Vector2 CartesianToPolar(Vector3 point)
{
Vector2 polar = new Vector2();
polar.y = Mathf.Atan2(point.x, point.z);
float xzLen = new Vector2(point.x, point.z).magnitude;
polar.x = Mathf.Atan2(-point.y, xzLen);
polar *= Mathf.Rad2Deg;
return polar;
}

public static List<PartResource> GetConnectedResources(Part part, String resourceName)
{
var resourceDef = PartResourceLibrary.Instance.GetDefinition(resourceName);
Expand Down
24 changes: 21 additions & 3 deletions Plugin/PartModules/KethaneDetectorAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public override void OnUpdate()
BaseT = BaseT.FindChild(BaseTransform);

Vector3 bodyCoords = BaseT.InverseTransformPoint(body.transform.position);
Vector2 pos = Misc.CartesianToPolar(bodyCoords);
Vector2 pos = cartesianToPolar(bodyCoords);

var alpha = (float)Misc.NormalizeAngle(pos.x + 90);
var beta = (float)Misc.NormalizeAngle(pos.y);
var alpha = (float)normalizeAngle(pos.x + 90);
var beta = (float)normalizeAngle(pos.y);

Transform RotH = BaseT.FindChild(HeadingTransform);
Transform RotV = RotH.FindChild(ElevationTransform);
Expand All @@ -59,5 +59,23 @@ public override void OnUpdate()
if (float.IsNaN(RotH.localRotation.w)) { RotH.localRotation = Quaternion.identity; }
if (float.IsNaN(RotV.localRotation.w)) { RotV.localRotation = Quaternion.identity; }
}

private static double normalizeAngle(double a)
{
a = a % 360;
if (a < 0)
a += 360;
return a;
}

private static Vector2 cartesianToPolar(Vector3 point)
{
Vector2 polar = new Vector2();
polar.y = Mathf.Atan2(point.x, point.z);
float xzLen = new Vector2(point.x, point.z).magnitude;
polar.x = Mathf.Atan2(-point.y, xzLen);
polar *= Mathf.Rad2Deg;
return polar;
}
}
}

0 comments on commit f624355

Please sign in to comment.