Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Straight Line on Polar Plot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rohan

India
12 Posts

Posted - 07 Jan 2014 :  00:49:21  Show Profile  Reply with Quote
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

1568 Posts

Posted - 07 Jan 2014 :  09:10:09  Show Profile  Reply with Quote
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 8-sided 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.
Go to Top of Page

Rohan

India
12 Posts

Posted - 16 Jan 2014 :  06:45:18  Show Profile  Reply with Quote
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.
Go to Top of Page

quinncurtis

1568 Posts

Posted - 16 Jan 2014 :  09:02:22  Show Profile  Reply with Quote
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.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07