/* * StereoImageProjection.java 1.0 98/06/03 Carl Burke * * Provides a stereo projection of data on a sphere. * * Copyright (c) 1998 Carl Burke. * * Derived from code in planet.c Copyright 1998 Torben AE. Mogensen */ public class StereoImageProjection extends ImageProjection { public StereoImageProjection(int w, int h, SolidNoiseGenerator sng) { super(w, h, sng); } double ymin; double ymax; public void renderTerrain() { double x,y,z,zz,x1,y1,z1,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; z = x*x+y*y; zz = 0.25*(4.0+z); x = x/zz; y = y/zz; z = (1.0-0.25*z)/zz; 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