public static Vector3 Convert(SphericalPoint point) { Vector3 output = new Vector3(); float plane = point.Radius * Mathf.Cos(Mathf.Deg2Rad * point.Elevation); output.x = plane * Mathf.Cos(Mathf.Deg2Rad * (point.Polar - 90)); output.y = point.Radius * Mathf.Sin(Mathf.Deg2Rad * point.Elevation); output.z = plane * Mathf.Sin(Mathf.Deg2Rad * (point.Polar - 90)); return output; }
public static SphericalPoint Convert(Vector3 point) { SphericalPoint output = new SphericalPoint(); if (point.x == 0) { point.x = Mathf.Epsilon; } output.Radius = Mathf.Sqrt((point.x * point.x) + (point.y * point.y) + (point.z * point.z)); output.Polar = Mathf.Atan(point.z / point.x); if (point.x < 0) { output.Polar += Mathf.PI; } output.Polar = (Mathf.Rad2Deg * output.Polar)-90; output.Elevation = Mathf.Rad2Deg * Mathf.Asin(point.y / output.Radius); return output; }
public bool Equals(SphericalPoint other) { return Radius == other.Radius && Polar == other.Polar && Elevation == other.Elevation; }