Example4_8.ChartStyle.RNorm C# (CSharp) Method

RNorm() public method

public RNorm ( float r ) : float
r float
return float
        public float RNorm(float r)
        {
            float rNorm = new float ();
            Rectangle rect = SetPolarArea ();
            if (r < RMin || r > RMax) {
                r = Single.NaN;
            }
            rNorm = (r - RMin) * rect.Width / 2 / (RMax - RMin);
            return rNorm;
        }

Usage Example

        public void AddPolar(Graphics g, ChartStyle cs)
        {
            Rectangle rect = cs.SetPolarArea();
            float     xc   = rect.X + rect.Width / 2;
            float     yc   = rect.Y + rect.Height / 2;

            // Plot lines:
            foreach (DataSeries ds in DataSeriesList)
            {
                Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
                aPen.DashStyle = ds.LineStyle.Pattern;
                float r     = ((PointF)ds.PointList [0]).Y;
                float theta = ((PointF)ds.PointList [0]).X;
                float x     = cs.RNorm(r) * (float)Math.Cos(theta * Math.PI / 180) + xc;
                float y     = cs.RNorm(r) * (float)Math.Sin(theta * Math.PI / 180) + yc;

                if (ds.LineStyle.IsVisible == true)
                {
                    PointF ptStart = new PointF(x, y);
                    PointF ptEnd   = new PointF(x, y);
                    for (int i = 1; i < ds.PointList.Count; i++)
                    {
                        r     = ((PointF)ds.PointList [i - 1]).Y;
                        theta = ((PointF)ds.PointList [i - 1]).X;
                        if (cs.AngleDirection == ChartStyle.AngleDirectionEnum.CounterClockWise)
                        {
                            theta = -theta;
                        }
                        x       = cs.RNorm(r) * (float)Math.Cos(theta * Math.PI / 180) + xc;
                        y       = cs.RNorm(r) * (float)Math.Sin(theta * Math.PI / 180) + yc;
                        ptStart = new PointF(x, y);
                        r       = ((PointF)ds.PointList [i]).Y;
                        theta   = ((PointF)ds.PointList [i]).X;
                        if (cs.AngleDirection == ChartStyle.AngleDirectionEnum.CounterClockWise)
                        {
                            theta = -theta;
                        }
                        x     = cs.RNorm(r) * (float)Math.Cos(theta * Math.PI / 180) + xc;
                        y     = cs.RNorm(r) * (float)Math.Sin(theta * Math.PI / 180) + yc;
                        ptEnd = new PointF(x, y);
                        g.DrawLine(aPen, ptStart, ptEnd);
                    }
                }
                aPen.Dispose();
            }
        }
All Usage Examples Of Example4_8.ChartStyle::RNorm