Author 
Topic 

Rohan
India
12 Posts 
Posted  07 Jan 2014 : 00:49:21

Hello,
How can i draw a straight line joining 2 points, on a polar graph.
if i user the "PolarLinePlot" class it does not draw a straight line. it draws a curve connecting 2 points. What i want is a straight line.
So, I have tried but the line does not come accurate????
Please guide as to what is wrong. Or if you have any better code, please suggest.
I tried the below code:
public void DrawLine(ChartView chartVu, PolarCoordinates pPolarTransform, double x1, double y1, double x2, double y2) { PathGeometry linepath = new PathGeometry(); Point startp = new Point(x1, y1); Point stopp = new Point(x2, y2); LineGeometry linegeo = new LineGeometry(startp, stopp); linepath.AddGeometry(linegeo); ChartShape titleLineShape = new ChartShape(pPolarTransform, linepath, ChartObj.POLAR_POS, 0, 0, ChartObj.POLAR_POS, 0); titleLineShape.SetLineWidth(2); titleLineShape.SetColor(Colors.Red); chartVu.AddChartObject(titleLineShape); } 
Edited by  Rohan on 07 Jan 2014 03:21:39 

quinncurtis
1571 Posts 
Posted  07 Jan 2014 : 09:10:09

Straight lines are what is not accurate in a polar chart. If you see a polar chart where data points are connected using straight lines, you can assume the developers really don't understand polar coordinates. We use polar coordinates interpolation for all plot drawing of data points specified using polar coordinates, which will draw curved lines between adjacent data points of different polar angle. For example, if you specify 8 data points of a constant magnitude, but a phase angle incrementing from 0 to 360 degrees, you expect a perfect circle. If the software was to display an 8sided polygon, using straight lines to connect the data points, that would be a serious error. But many software packages will do just that.
Please describe exactly what you are trying to create using straight lines, because other than drawing axes, and other similar objects which are not actually data plots, they have no place in a polar chart. When we plot the polar axes, we don't actually use the polar coordinate system, we plot those elements using an underlying Cartesian coordinate system. 


Rohan
India
12 Posts 
Posted  16 Jan 2014 : 06:45:18

Hello, My requirement is like, I have two points on polar and i am calculating midpoint of these two. now i need to join all these three points in straight line so that user can see the midpoint calculated is correct one.
Please suggest. 


quinncurtis
1571 Posts 
Posted  16 Jan 2014 : 09:02:22

Just to verify. In Polar (or Antenna) coordinates, the midpoint between two points, [magnitude1, angle1] and [magnitude2, angle2] is [(magnitude1 + magnitude2)/2, (angle1 + angle2)/2]. This point lies on a curve between the two points. It is NOT the same point as finding the straight line Cartesian coordinates midpoint between two polar points. So, verify that you want the Cartesian coordinates midpoint between two polar points, rather than the Polar coordinates midpoint.
I ran your original DrawLine method, and it did draw a straight line between two polar points, as seen in the picture below. This is what the call looked like: DrawLine(chartVu, pPolarTransform, 100, ChartSupport.ToRadians(30), 90, ChartSupport.ToRadians(150));
The DrawLine method draws a straight line, because the ChartShape class it uses does not invoke the polar coordinate interpolation routines that the PolarLinePlot class does.
So I do not know what you want.




Topic 


