using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Txgy.EWS.Client.FocalMechanism.Model { public class Line : Graph { public int angle; public double dis; public double p1x; public double p1y; public double p2x; public double p2y; public Line(int a, double d) { angle = a; dis = d; } public void compute(double xmax, double xmin, double ymax, double ymin) { if (angle == 90) { p1x = p2x = 0 - dis; p1y = ymin; p2y = ymax; return; } double tan = Math.Tan(angle * Math.PI / 180); double cos = Math.Cos(angle * Math.PI / 180); double sin = Math.Sin(angle * Math.PI / 180); p2x = xmax; p2y = p2x * tan + dis / cos; p1x = xmin; p1y = p1x * tan + dis / cos; //make sure point 1 is under point 2 if (p1y > p2y) { double tem = p1x; p1x = p2x; p2x = tem; tem = p1y; p1y = p2y; p2y = tem; } if (p2y > ymax) { p2y = ymax; p2x = p2y / tan - dis / sin; } if (p1y < ymin) { p1y = ymin; p1x = p1y / tan - dis / sin; } } } }