title: Texture Resultion Problems
body: <p>I am trying to write a mini graphics engine for university project ,
  so I added a texture to the engine with plane it works pretty good <a href="https://i.stack.imgur.com/lDryB.jpg" rel="nofollow noreferrer">Plane Picture</a></p>
  <p>but with sphere it work really bad even if the radius of sphere is really big ( 9000) .
  <a href="https://i.stack.imgur.com/BB7Ne.jpg" rel="nofollow noreferrer">Sphere Image</a></p>
  <p>I used this formula :
  (In class point) :</p>
  <pre><code>  public class LongLat{
          public double lat; 
          public double lon; 
          LongLat(double x1, double x2){
              lat = x1 ;
              lon = x2 ; 
          }
  
      }
  
       final   double E = 0.0000000848191908426;
       final  double D2R = Math.PI / 180;
       final double PiDiv4 = Math.PI / 4;
     final double HalfPi = Math.PI / 2;
     private final double C1 = 0.00335655146887969;
     private final double C2 = 0.00000657187271079536;
     private final double C3 = 0.00000001764564338702;
     private final double C4 = 0.00000000005328478445;
      public  LongLat ToLonLat( double Radius)
      {
          double x =this.xyz.d1 ; 
           double y = this.xyz.d3 ;
          double g = HalfPi - 2 * Math.atan(1 / Math.exp(y / Radius));
          double latRadians = g + C1 * Math.sin(2 * g) + C2 * Math.sin(4 * g) + C3 * Math.sin(6 * g) + C4 * Math.sin(8 * g);
  
          double lonRadians = x / Radius;
  
          double lon = lonRadians / D2R ;
          double lat = latRadians / D2R ;
  
          return new LongLat((float)lon, (float)lat);
      }
  </code></pre>
  <p>(In TSphere- Texture Sphere class ):</p>
  <pre><code>    Point.LongLat lt =pt.point.ToLonLat(sp.radius );
       double longitude = lt.lon ; 
       double latitude = lt.lat; 
      double PI = Math.PI; 
      // get x value
      int x = (int)(longitude+180)*(nX/360); 
  
      // convert from degrees to radians
      double latRad = latitude*PI/180;
  
      // get y value
      double  mercN = Math.log(Math.tan((PI/4)+(latRad/2)));
      int y = (int)( (nY/2)-(nX*mercN/(2*PI)));
      int color = image.getRGB(x % nX ,  y% nY ); 
      Color xc = new Color(new java.awt.Color(color));
      return xc ;  
  </code></pre>
  <p>and it looks really pixelated for some reason , someone have an  idea how to fix that ?
  Thanks Idan.</p>