/* * GnomonicImageProjection.java 1.0 98/06/03 Carl Burke * * Provides a gnomonic projection of data on a sphere. * * Copyright (c) 1998 Carl Burke. * * Derived from code in planet.c Copyright 1998 Torben AE. Mogensen */ public class GnomonicImageProjection extends ImageProjection { public GnomonicImageProjection(int w, int h, SolidNoiseGenerator sng) { super(w, h, sng); } double ymin; double ymax; public void renderTerrain() { double x,y,z,x1,y1,z1,zz,theta1,theta2; int i,j; ymin = 2.0; ymax = -2.0; SNG.setScaling(scale, Width, Height); for (j = 0; j < Height; j++) { for (i = 0; i < Width ; i++) { x = (2.0*i-Width)/Height/scale; y = (2.0*j-Height)/Height/scale; zz = Math.sqrt(1.0/(1.0+x*x+y*y)); x = x*zz; y = y*zz; z = Math.sqrt(1.0-x*x-y*y); x1 = clo*x+slo*sla*y+slo*cla*z; y1 = cla*y-sla*z; z1 = -slo*x+clo*sla*y+clo*cla*z; if (y1 < ymin) ymin = y1; if (y1 > ymax) ymax = y1; pixels[j*Width+i] = SNG.color(x1,y1,z1); } } } public void renderLatitudes() { double x,y,z,x1,y1,z1,zz,theta1,theta2; int i,j,k; for (theta1 = 0.0; theta1>-90.0; theta1-=hgrid); for (theta1 = theta1; theta1<90.0; theta1+=hgrid) { y = Math.sin(DEG2RAD*theta1); if (ymin <= y && y <= ymax) { zz = Math.sqrt(1-y*y); for (theta2=-Math.PI; theta2