/* Copyright 2001 by Ralph Hartley This software is licenced under the terms of the Gnu Public Licence */ import java.io.*; import java.util.*; import org.w3c.dom.*; public class Shot implements Serializable,Comparable,Displacement { private static final long serialVersionUID = 38512345874339L; public Station from; public Station to; public double dist = 0; public double az = 0; public double inc = 0; public String diststr; public String azstr; public String incstr; Element element; public Shot(Station from,Station to,String dist,String az,String inc,String unit,Element element) { this.azstr=az; this.incstr=inc; this.diststr=dist; if (az!=null) { try { this.az = Double.parseDouble(az); } catch (NumberFormatException ex) {} } if (inc!=null) { try { this.inc = Double.parseDouble(inc); } catch (NumberFormatException ex) {} } if (dist!=null) { try { this.dist = Double.parseDouble(dist); } catch (NumberFormatException ex) {} } if (unit != null) { if (unit.equals("meters")) this.dist *= 3.281; if (unit.equals("yards")) this.dist *= 3; } this.from=from; this.to=to; to.shots.add(this); from.shots.add(this); this.element = element; } public double vertical() { return(dist * Math.sin(Math.PI*inc/180)); } public double verticalVar() { double std = dist * Math.cos(Math.PI*inc/180); return(std*std); } public void reverse() { Station temp = from; from = to; to = temp; az = (az + 180 +360)%360; inc = -inc; } public String toString() { return("SHOT:"+from+"-"+to); } public int compareTo(Object that) { return(toString().compareTo(that.toString())); } public boolean equals(Object that) { return(toString().equals(that.toString())); } }