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> /// Calculates the circles (or curved lines when not completely in view) /// </summary> /// <param name="viewport"></param> /// <param name="dec"></param> private void CalculateDecPoints(double dec) { var thickness = dec == 0 ? 3 : 1; var coordinates = decCoordinateMatrix[dec]; var center = currentViewport.CenterCoordinates; var startRA = coordinates.Aggregate((x, y) => Math.Abs(x.RADegrees - center.RADegrees) < Math.Abs(y.RADegrees - center.RADegrees) ? x : y); var startIdx = coordinates.FindIndex(x => startRA.RADegrees == x.RADegrees); var iterator = 0; var list = new LinkedList <PointF>(); if (currentViewport.ContainsCoordinates(startRA)) { var pointF = Project(startRA); list.AddLast(pointF); do { iterator++; var rightCoordinate = coordinates[(int)nfmod((startIdx + iterator), coordinates.Count)]; var leftCoordinate = coordinates[(int)nfmod((startIdx - iterator), coordinates.Count)]; var leftPointF = Project(leftCoordinate); var rightPointF = Project(rightCoordinate); list.AddLast(leftPointF); list.AddFirst(rightPointF); if (!currentViewport.ContainsCoordinates(leftCoordinate) && !currentViewport.ContainsCoordinates(rightCoordinate)) { break; } } while (iterator <= coordinates.Count / 2d); } DecPoints.Add(new FrameLine() { Collection = new List <PointF>(list), StrokeThickness = thickness, Closed = false, Angle = Angle.ByDegree(dec) }); }