using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using Txgy.EWS.Client.FocalMechanism.Model; namespace Txgy.EWS.Client.FocalMechanism.Core { public class Factory { protected static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); public FmGrid grid { get; set; } public Factory(FmGrid g) { this.grid = g; } public Point[] getPoints(Polygon p) { int l = p.upperBound.Count + p.lowerBound.Count; Point[] pArray = new Point[l]; int j = 0; for (int i = 0; i < p.upperBound.Count; i++) { pArray[j++] = new Point(getX(p.upperBound[i].X), getY(p.upperBound[i].Y)); } for (int i = p.lowerBound.Count - 1; i >= 0; i--) { pArray[j++] = new Point(getX(p.lowerBound[i].X), getY(p.lowerBound[i].Y)); } return pArray; } public static double sin(int angle) { return Math.Sin(angle * Math.PI / 180); } public static double cos(int angle) { return Math.Cos(angle * Math.PI / 180); } public static double tan(int angle) { return Math.Tan(angle * Math.PI / 180); } public int getX(double x) { double d = (x - grid.Xmin) / (grid.Xmax - grid.Xmin) * 900 + 50; return (int)d; } public int getY(double y) { double d = 950 - (y - grid.Ymin) / (grid.Ymax - grid.Ymin) * 900; return (int)d; } } }