void UpdateGraph() { string text = ""; // Estimate coeffs double thetaMax = floatTrackbarControlThetaMax.Value * 0.5 * Math.PI / 90.0; for (int l = 0; l <= MAX_ORDER; l++) { coeffs[l] = (float)EstimateSHCoeff(l, thetaMax); text += "SH #" + l + " = " + coeffs[l] + "\r\n"; } m_image.Clear(m_white); // m_image.PlotGraphAutoRangeY( m_black, rangeX, ref rangeY, ( float x ) => { m_image.PlotGraph(m_black, rangeX, rangeY, ( float x ) => { int l0 = Math.Min(MAX_ORDER, (int)Math.Floor(x)); float A0 = coeffs[l0]; int l1 = Math.Min(MAX_ORDER, l0 + 1); float A1 = coeffs[l1]; x = x - l0; return(A0 + (A1 - A0) * x); }); // Plot A0, A1 and A2 terms double C = Math.Cos(thetaMax); // m_image.PlotGraph( m_red, rangeX, rangeY, ( float x ) => { return (float) (Math.Sqrt( Math.PI ) * (1.0 - C*C) / 2.0); } ); // m_image.PlotGraph( m_green, rangeX, rangeY, ( float x ) => { return (float) (Math.Sqrt( 3.0 * Math.PI ) * (1.0 - C*C*C) / 3.0); } ); // m_image.PlotGraph( m_blue, rangeX, rangeY, ( float x ) => { return (float) (Math.Sqrt( 5.0 * Math.PI / 4.0 ) * (3.0/4.0 * (1.0 - C*C*C*C) - 1.0 / 2.0 * (1 - C*C))); } ); PlotSquare(m_red, rangeX, rangeY, new float2(0, (float)(Math.Sqrt(Math.PI) * (1.0 - C * C) / 2.0))); PlotSquare(m_green, rangeX, rangeY, new float2(1, (float)(Math.Sqrt(Math.PI / 3.0) * (1.0 - C * C * C)))); PlotSquare(m_blue, rangeX, rangeY, new float2(2, (float)(Math.Sqrt(5.0 * Math.PI / 4.0) * (3.0 / 4.0 * (1.0 - C * C * C * C) - 1.0 / 2.0 * (1 - C * C))))); m_image.PlotAxes(m_black, rangeX, rangeY, 1, 0.1f); text += "\r\nRange Y = [" + rangeY.x + ", " + rangeY.y + "]\r\n"; textBoxResults.Text = text; graphPanel.Bitmap = m_image.AsBitmap; graphPanel.EnablePaint = true; graphPanel.Refresh(); floatTrackbarControlThetaMax.Refresh(); textBoxResults.Refresh(); }