00001
00002
00003
00004
00005
00006 namespace NewGamePhysics.Mathematics
00007 {
00008 using System;
00009
00020 public class EquirectangularProjection
00021 {
00028 public static double lonToX(double lon)
00029 {
00030 if ((lon < 0) || (lon > 360.0))
00031 {
00032 throw new ArgumentOutOfRangeException("lon");
00033 }
00034
00035 return lon / 360.0;
00036 }
00037
00044 public static double latToY(double lat)
00045 {
00046 if ((lat < -90.0) || (lat > 90.0))
00047 {
00048 throw new ArgumentOutOfRangeException("lat");
00049 }
00050
00051 return (lat / 90.0 + 1.0) / 2.0;
00052 }
00053
00060 public static double xToLon(double x)
00061 {
00062 if ((x < 0.0) || (x > 1.0))
00063 {
00064 throw new ArgumentOutOfRangeException("lon");
00065 }
00066
00067 return x * 360.0;
00068 }
00069
00076 public static double yToLat(double y)
00077 {
00078 if ((y < 0.0) || (y > 1.0))
00079 {
00080 throw new ArgumentOutOfRangeException("lon");
00081 }
00082
00083 return y * 180.0 - 90.0;
00084 }
00085 }
00086 }