/*
* OrthographicImageProjection.java 1.0 98/06/03 Carl Burke
*
* Provides an orthographic projection of data on a sphere.
*
* Copyright (c) 1998 Carl Burke.
*
* Derived from code in planet.c Copyright 1998 Torben AE. Mogensen
*/
public class OrthographicImageProjection extends ImageProjection
{
public OrthographicImageProjection(int w, int h, SolidNoiseGenerator sng)
{
super(w, h, sng);
}
double ymin;
double ymax;
public void renderTerrain()
{
double x,y,z,x1,y1,z1,theta1,theta2,zz;
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;
if (x*x+y*y>1.0) pixels[j*Width+i] = SNG.background();
else {
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=z1){
i = (int)(0.5*(Height*scale*x1+Width));
j = (int)(0.5*(Height*scale*y1+Height));
if (0<=i && i=z1){
i = (int)(0.5*(Height*scale*x1+Width));
j = (int)(0.5*(Height*scale*y1+Height));
if (0<=i && i