/// <summary> /// Calculates distance between this point and the input point. Uses approximation for cosine for small angles. /// </summary> /// <param name="iPoint">Second point used for calculating distance.</param> /// <returns>Distance between the two points.</returns> public double Distance(BasePoint iPoint) { int xDif = Math.Abs(iPoint.X - this.X); if (xDif > _mapSize) { xDif = 2 * _mapSize - xDif; } double cosDif; if (xDif < _mapSize / 6) { cosDif = 1 - (0.5 * xDif * xDif * _angleSize * _angleSize); } else { cosDif = Math.Cos((double)xDif * _angleSize); } return(Math.Abs(2 * (1 - _sinPhi * iPoint._sinPhi - _cosPhi * iPoint._cosPhi * cosDif))); }
/// <summary> /// Allocates space for arrays and sets up the point class. /// </summary> /// <param name="iSize">Size of the map, see <see cref="_layerSize"/></param> /// <param name="iNumberPlates">Number of plates in <see cref="Plates"/></param> public PlateLayer(int iSize, int iNumberPlates) { _layerSize = iSize; BasePoint.MapSetup(iSize); Plates = new Plate[iNumberPlates]; for (int i = 0; i < Plates.Length; i++) { Plates[i] = new Plate(); } temporaryPlate = new Plate(); ActivePoints = new bool[2 * _layerSize, _layerSize]; PastPlates = new int[2 * _layerSize, _layerSize]; PastHeights = new double[2 * _layerSize, _layerSize]; PointMagnitudes = new double[2 * _layerSize, _layerSize]; PointMap = new BasePoint[2 * _layerSize, _layerSize]; for (int x = 0; x < 2 * _layerSize; x++) { for (int y = 0; y < _layerSize; y++) { PointMap[x, y] = new BasePoint(x, y); } } }
/// <summary> /// Constructor for Plate Point. /// </summary> /// <param name="inPoint"> Input coordinates for new point.</param> /// <param name="inHeight">Height of Plate Point, defaults to 0.</param> public PlatePoint(SimplePoint inPoint, double inHeight = 0) { _point = new BasePoint(inPoint); Height = inHeight; }
/// <summary> /// Constructor for Plate Point. /// </summary> /// <param name="inPoint"> Input coordinates for new point.</param> /// <param name="inHeight">Height of Plate Point, defaults to 0.</param> public PlatePoint(BasePoint inPoint, double inHeight = 0) { _point = inPoint; Height = inHeight; }
/// <summary> /// Constructor for Plate Point. /// </summary> /// <param name="inX">X coordinate for point.</param> /// <param name="inY">Y coordinate for point.</param> /// <param name="inHeight">Height of Plate Point, defaults to 0.</param> public PlatePoint(int inX, int inY, double inHeight = 0) { _point = new BasePoint(inX, inY); Height = inHeight; }