public void CalculatePoints(ViewportFoV viewport) { // calculate the lines based on fov height and current dec to avoid projection issues // atan gnomoric projection cannot project properly over 90deg, it will result in the same results as prior // and dec lines will overlap each other var(raStep, decStep, raStart, raStop, decStart, decStop) = CalculateStepsAndStartStopValues(viewport); var pointsByDecDict = new Dictionary <double, FrameLine>(); // if raStep is 30 and decStep is 1 just bool raIsClosed = RoundToHigherValue(viewport.AbsCalcTopDec, decStep) >= MAXDEC; for (double ra = Math.Min(raStart, raStop); ra <= Math.Max(raStop, raStart); ra += raStep) { List <PointF> raPointCollection = new List <PointF>(); for (double dec = Math.Min(decStart, decStop); dec <= Math.Max(decStart, decStop); dec += decStep) { var point = new Coordinates(ra, dec, Epoch.J2000, Coordinates.RAType.Degrees).XYProjection(viewport); var pointf = new PointF((float)point.X, (float)point.Y); if (!pointsByDecDict.ContainsKey(dec)) { pointsByDecDict.Add(dec, new FrameLine() { Closed = raIsClosed, Collection = new List <PointF> { pointf }, StrokeThickness = dec == 0 ? 3 : 1 }); } else { pointsByDecDict[dec].Collection.Add(pointf); } raPointCollection.Add(pointf); } // those are the vertical lines RAPoints.Add(new FrameLine { StrokeThickness = (ra == 0 || ra == 180) ? 3 : 1, Closed = false, Collection = raPointCollection }); } // those are actually the circles foreach (KeyValuePair <double, FrameLine> item in pointsByDecDict) { DecPoints.Add(item.Value); } }
/// <summary> /// Calculate the lines spanning from pole to pole /// </summary> /// <param name="viewport"></param> /// <param name="ra"></param> private void CalculateRAPoints(double ra) { var list = new List <PointF>(); var thickness = 1; Coordinates prevCoordinate = null; bool atLeastOneInside = false; foreach (var coordinate in raCoordinateMatrix[ra]) { if (currentViewport.ContainsCoordinates(coordinate)) { atLeastOneInside = true; if (prevCoordinate != null) { list.Add(Project(prevCoordinate)); prevCoordinate = null; } if (coordinate.RADegrees == 0 || coordinate.RADegrees == 180) { thickness = 3; } list.Add(Project(coordinate)); } else { if (atLeastOneInside) { list.Add(Project(coordinate)); break; } else { prevCoordinate = coordinate; } } } RAPoints.Add(new FrameLine() { Collection = list, StrokeThickness = thickness, Closed = false, Angle = Angle.ByDegree(ra) }); }