/* * Globe.java (requires Java 1.2+) */ import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; import java.util.*; class GlobeCanvas extends Component { BufferedImage image; int w, h; GlobeCanvas(BufferedImage _image) { image= _image; w = image.getWidth(null); h = image.getHeight(null); setSize(w, h); } public void paint(Graphics g) { //System.out.println("GlobeCanvas.paint()"); g.drawImage(image, 0, 0, w, h, null); } } //------------------------------------------------------------------------------------------- class GlobeImage extends BufferedImage { double rotbyd, rotbyr, cosine, sine; double rad; int w, h; Vector lines; class line { double p0[]; double p1[]; Color color; line(double _p0[], double _p1[], Color _color) { p0= new double[3]; p0[0]= _p0[0]; p0[1]= _p0[1]; p0[2]= _p0[2]; p1= new double[3]; p1[0]= _p1[0]; p1[1]= _p1[1]; p1[2]= _p1[2]; color = _color; } } GlobeImage() { super(400, 400, BufferedImage.TYPE_3BYTE_BGR); w= 400; h= 400; rad= 150; rotbyd= 15; rotbyr= rotbyd* 3.14159/180; cosine= Math.cos(rotbyr); sine= Math.sin(rotbyr); createLines(); } static double[] AltAzToXYZ(double alt, double az) { double altrad= (3.14159/180.0)* -alt; double azrad= (3.14159/180.0)* -az; double abscosaltrad= Math.abs(Math.cos(altrad)); double x= Math.sin(azrad)* abscosaltrad; double y= Math.sin(altrad); double z= Math.cos(azrad)* abscosaltrad; //print '(%i, %i)-> (%i, %i, %i)' % (alt, az, x, y, z) double[] ret = new double[3]; ret[0]= x; ret[1]= y; ret[2]= z; return ret; } static void MultByRad(double[] xyz, double _rad) { xyz[0]*= _rad; xyz[1]*= _rad; xyz[2]*= _rad; } final void Rotate1(double[] pt) { double x= pt[0]; double y= pt[1]; double x2= (x*cosine) + (y*sine); double y2= -(x*sine) + (y*cosine); pt[0]= x2; pt[1]= y2; } final void Rotate2(double[] pt) { double x= pt[1]; double y= pt[2]; double x2= (x*cosine) + (y*sine); double y2= -(x*sine) + (y*cosine); pt[1]= x2; pt[2]= y2; } final void draw_line(double[] p0, double[] p1, Color color) { Graphics g= createGraphics(); g.setColor(color); int w2= w/2; int h2= h/2; g.drawLine((int)p0[0]+w2, (int)p0[1]+h2, (int)p1[0]+w2, (int)p1[1]+h2); } public void draw() { int w2= w/2; int h2= h/2; Graphics g= createGraphics(); g.setColor(Color.white); g.fillRect(0, 0, w, h); for (int i=0; i