public void drawEquation()
        {
            _3DPoint previousPoint = new _3DPoint();

            previousPoint.z = -1000;
            for (int i = 0; i < P.Length; i++)
            {
                if (P[i].z > previousPoint.z)
                {
                    previousPoint = P[i];
                }
            }
            Graphics g      = this.CreateGraphics();
            Font     myFont = new Font(FontFamily.GenericMonospace, 15);
            Brush    b      = new SolidBrush(Color.YellowGreen);

            if (radioButton1.Checked)
            {
                g.DrawString("4sin((x^2 +y^2)^1/2)/(x^2 + y^2)^1/2)", myFont, b, new PointF(previousPoint.x, previousPoint.y));
            }
            else if (radioButton2.Checked)
            {
                g.DrawString("x^2+y^2", myFont, b, new PointF(previousPoint.x, previousPoint.y));
            }
        }
 public _3DPoint(_3DPoint p)
 {
     this.x = p.x;
     this.y = p.y;
     this.z = p.z;
     this.c = p.c;
 }
        public void initializePoints(int size)
        {
            if (!radioButton4.Checked)
            {
                P = new _3DPoint[(2 * size) * (2 * size) * 5 * 5];
                double xCount = -size;
                double yCount = -size;
                _3DPoint.inMiddle = 60 * (int)Math.Pow(4 * (size + size), 2) / P.Length;
                for (int i = 0; i < P.Length && xCount < size; i += 1)
                {
                    P[i]   = new _3DPoint();
                    P[i].x = (float)xCount;
                    P[i].y = (float)yCount;
                    P[i].z = equation(P[i].x, P[i].y);
                    P[i].calculateColor();
                    yCount = Math.Round(yCount, 1);
                    if (yCount == size)
                    {
                        yCount  = -size;
                        xCount += 0.2;
                    }
                    else
                    {
                        yCount += 0.2;
                    }
                }
            }
            else
            {
                P = new _3DPoint[8];

                P[0] = new _3DPoint(); P[0].x = 1; P[0].y = -1; P[0].z = -1;
                P[1] = new _3DPoint(); P[1].x = 1; P[1].y = -1; P[1].z = 1;
                P[2] = new _3DPoint(); P[2].x = 1; P[2].y = 1; P[2].z = -1;
                P[3] = new _3DPoint(); P[3].x = 1; P[3].y = 1; P[3].z = 1;
                P[4] = new _3DPoint(); P[4].x = -1; P[4].y = -1; P[4].z = -1;
                P[5] = new _3DPoint(); P[5].x = -1; P[5].y = -1; P[5].z = 1;
                P[6] = new _3DPoint(); P[6].x = -1; P[6].y = 1; P[6].z = -1;
                P[7] = new _3DPoint(); P[7].x = -1; P[7].y = 1; P[7].z = 1;
                for (int i = 0; i < 8; i++)
                {
                    P[i].c = Color.White;
                }
                //FindAllProximity();
            }
        }
        //MAYBE LATER
        //if ((locations[x].y != int.Parse(textBox1.Text)) && (x + 1 < locations.Length))
        //        {
        //            g.DrawLine(p,new PointF(locations[x].x, locations[x].y), new PointF(locations[x + 1].x, locations[x + 1].y)
        //        }
        //double Pd = 1000;
        //        PointF nearestPoint = new PointF();
        //        for (int i = 0; i < locations.Length; i++)
        //        {
        //            if (locations[i] != locations[x])
        //            {
        //                double d = Math.Sqrt(Math.Pow(locations[x].x - locations[i].x, 2) + Math.Pow(locations[x].y - locations[i].y, 2));
        //                if(d < Pd)
        //                {
        //                    nearestPoint = new PointF(20 * locations[i].x + center.X, 20 * locations[i].y + center.Y);
        //                }
        //                Pd = d;
        //            }

        //        }
        //        PointF drawTo = new PointF(20 * locations[x].x + center.X, 20 * locations[x].y + center.Y);
        //        g.DrawLine(p, drawTo, nearestPoint);
        public _3DPoint[] multiplyMartix(_3DPoint[] P, double[][] R)
        {
            _3DPoint[] newMatrix = new _3DPoint[P.Length];
            for (int i = 0; i < newMatrix.Length; i++)
            {
                //if (P[i] != null)
                //{
                newMatrix[i]           = new _3DPoint();
                newMatrix[i].x         = (float)(P[i].x * R[0][0] + P[i].y * R[0][1] + P[i].z * R[0][2]); //new x value
                newMatrix[i].y         = (float)(P[i].x * R[1][0] + P[i].y * R[1][1] + P[i].z * R[1][2]); //new y value
                newMatrix[i].z         = (float)(P[i].x * R[2][0] + P[i].y * R[2][1] + P[i].z * R[2][2]);
                newMatrix[i].c         = P[i].c;
                newMatrix[i].proximity = P[i].proximity;
                // }
            }
            return(newMatrix);
        }