Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing programmatically using C# in Silverlight
    text
    copied!<p>I am trying to create an Aitoff-Hammer grid in Silverlight using C#. It should look like <a href="http://grb.sonoma.edu:81/sl/aitoff.JPG" rel="nofollow noreferrer">this</a> minus the dots and numbers.</p> <p>I am not a programmer but have been able to piece together <a href="http://grb.sonoma.edu:81/sl/TestPage.html" rel="nofollow noreferrer">this</a> using an ActionScript file to do the same thing that was written by my predecessor. As you can see, I get the grid plus unwanted diagonal lines. I am not sure how to avoid having the diagonal lines from being drawn in my code.</p> <p>Any help anyone can provide to fix my problem or point out what I may be doing wrong will be much appreciated. Please let me know if I left out important information. Thanks.</p> <p>Here is my code:</p> <pre><code>PolyLineSegment segment = new PolyLineSegment(); PathFigure figure = new PathFigure(); figure.StartPoint = new Point(xCenter, yCenter); PathGeometry geometry = new PathGeometry(); Path path = new Path(); path.Stroke = new SolidColorBrush(Colors.Black); path.StrokeThickness = 2; aitoff coords = new aitoff(); for (int ra = 0; ra &lt;= 24; ra = ra + 3) { for (int dec = -90; dec &lt;= 90; dec = dec + 3) { points = coords.GetAitoffCoord(ra, dec); double xCoord = xCenter + points.X * width / 2; double yCoord = yCenter + points.Y * height / 2; segment.Points.Add(new Point(xCoord, yCoord)); } } for (int dec = -90; dec &lt;= 90; dec = dec + 30) { for (int ra = 0; ra &lt;= 12; ra = ra + 1) { points = coords.GetAitoffCoord(ra, dec); double xCoord = xCenter + points.X * width / 2; double yCoord = yCenter + points.Y * height / 2; segment.Points.Add(new Point(xCoord, yCoord)); } } for (int dec = -90; dec &lt;= 90; dec = dec + 30) { for (double ra = 12.01; ra &lt;= 25; ra++) { points = coords.GetAitoffCoord(ra, dec); double xCoord = xCenter + points.X * width / 2; double yCoord = yCenter + points.Y * height / 2; segment.Points.Add(new Point(xCoord, yCoord)); } } for (int dec = -90; dec &lt;= 90; dec = dec + 3) { double ra = 12.01; points = coords.GetAitoffCoord(ra, dec); double xCoord = xCenter + points.X * width / 2; double yCoord = yCenter + points.Y * height / 2; segment.Points.Add(new Point(xCoord, yCoord)); } figure.Segments.Add(segment); geometry.Figures.Add(figure); path.Data = geometry; LayoutRoot.Children.Add(path); // GetAitoff public class aitoff { double ra; double dec; Point coords = new Point(); double ra2deg = Math.PI / 180.0f; public Point GetAitoffCoord(double raIn, double decIn) { ra = raIn * 360 / 24; dec = decIn; if (ra &gt; 180) ra = ra - 360; double l = ra * ra2deg; double b = dec * ra2deg; double t = Math.Sqrt(2 / (1 + Math.Cos(b) * Math.Cos(l / 2))); double x = 2 * t * Math.Cos(b) * Math.Sin(l / 2); double y = t * Math.Sin(b); coords.X = x / (-2 * Math.Sqrt(2)); coords.Y = y / (-1 * Math.Sqrt(2)); return coords; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload