/* JRG, the Resource Geology Seismic Processing System for Java, and Viewmat for Java are Copyright 1998-2000 by John N. Louie The software and methods here are the subject of academic research, not commercial products. I would like to know what use you make of my methods, and have your feedback on their success or failure. Also, by letting me know who you are, I can inform you if bugs or errors are discovered. Please send me an email message with: your name and email address; whether you are a student or faculty member, consultant or employee; the name of your university or company, and department; and a sentence or two describing what use you intend to make of these methods. Send your message to louie@seismo.unr.edu */ import java.io.*; public class RgHead { public int rec; /* field record number */ public int svp; /* source location number */ public int gvp; /* receiver location number */ public double sx; /* source x-coordinate, m */ public double sy; /* source y-coordinate, m */ public double sz; /* source z-coordinate, m */ public double gx; /* receiver x-coordinate, m */ public double gy; /* receiver y-coordinate, m */ public double gz; /* receiver z-coordinate, m */ public double off; /* offset, m, may be signed */ public byte unas[]; /* 3 unassigned bytes to keep 4-byte alignment */ public boolean allset; /* false if not all values set */ public static final int RGHEADBYTES = 18*4; public static double RAD=0.0174532; public static double DAR=57.29578; public static double COR=0.993306; /* COR= (1-e)**2, where e= ecentricity */ /* COR= 0.993306 for e=1.0/289.78 */ public static double TOL=0.001; public static double RTOL=0.001; public static double SQRT2=1.414213562; public static double PI=3.1415926; public static double FOURPI=12.56637062; public static double MPDEG=111190.0; /* Constructors */ RgHead() { unas = new byte[3]; allset = false; } /* Construct a copy */ RgHead(RgHead hd) { this.rec = hd.rec; this.svp = hd.svp; this.gvp = hd.gvp; this.sx = hd.sx; this.sy = hd.sy; this.sz = hd.sz; this.gx = hd.gx; this.gy = hd.gy; this.gz = hd.gz; this.off = hd.off; this.unas = new byte[3]; this.unas[0] = hd.unas[0]; this.unas[1] = hd.unas[1]; this.unas[2] = hd.unas[2]; this.allset = hd.allset; } /* Construct a header from FltPlane dimensional attributes */ RgHead(int iv, FltPlane fp) { int np=1, nv, ip; nv = fp.vecs; if (fp.getNMembofDim(2) > 1) { np = fp.getNMembofDim(2); nv = fp.vecs/np; if (np*nv != fp.vecs) { np = 1; nv = fp.vecs; } } ip = iv/nv; this.rec = ip; this.svp = ip; this.gvp = this.svp + iv - ip*nv; this.sx = fp.getUnit0ofDim(2) + ip*fp.getDUnitofDim(2); this.sy = 0.0; this.sz = 0.0; this.off = fp.getUnit0ofDim(1) + (iv - (ip*nv))*fp.getDUnitofDim(1); this.gx = this.sx + this.off; this.gy = 0.0; this.gz = 0.0; this.unas = new byte[3]; this.allset = false; } /* Find a projection line through source-point coordinates or midpoints. Returned svp and gvp set to location closest to origin; sx, sy, sz give origin coordinates; gx is Slope on map in meters North/meters East; gy is Direction in degrees East of North; gz is the distance in meters from the origin to the closest station off is the length of the projection */ public void getProjection(RgHead[] headers) { /* set defaults for a projection */ this.rec = 0; this.allset = true; /* Compute projection line from sx, sy in headers */ double sx = 0; double sx2 = 0; double sy = 0; double sy2 = 0; double sxy = 0; double m, b, ang, temp; RgHead[] coord = headers; int ncoord = coord.length; double westx = coord[0].sx; double westy = coord[0].sy; for (int icoord=0; icoord this.off) this.off = coord[i].sy; } this.off -= this.sy; } else { m = (sxy - sx*sy/ncoord)/(sx2 - sx*sx/ncoord); b = sy/ncoord - m*sx/ncoord; this.off = coord[0].sx; for (int i=1; i this.off) this.off = coord[i].sx; } if (m == 0.0) { /* W-E Projection Line */ ang = 90; this.sy = b; this.sx = westx; this.off -= this.sx; } else { temp = (b + westx/m -westy)/(1.0/m - m); this.sx = temp; this.sy = m*temp + b; ang = Math.atan2(1.0, m)/RAD; temp = m*this.off + b; this.off = Math.sqrt((this.off - this.sx)*(this.off - this.sx) + (temp - this.sy)*(temp - this.sy)); } } this.gx = m; this.gy = ang; /* find point in header closest to projection origin */ this.svp = coord[0].svp; this.sz = coord[0].sz; this.gz = (this.sx - coord[0].sx)*(this.sx - coord[0].sx) + (this.sy - coord[0].sy)*(this.sy - coord[0].sy); for (int i=1; i