Question : find out an (x,y) location of a point on a circle's edge C#

Hi,

I want to find out  (x,y) location of a points on a circle's edge. So that i can display text around circle.

I saw http://www.experts-exchange.com/Programming/Game/3D_Prog./Q_22940840.html
and used the code as given by Arthur_Wood: but it did not worked. Another thing where do we have to set the radius of circle.

Thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Float pi = 3.1415926f;
            double[] x1 = new double[12];
            double[] y1 = new double[11];
            
            for (int i = 0; i <= 11; i++)
            {
                x1[i] = -1 * Math.Cos(i * pi / 5);
                y1[i] = Math.Sin(i * pi / 5);
            }
            for (int count = 0; count <= 11; count++)
            {
                ggr.DrawLine(new Pen(Color.Black), x, y, (float)x1[count], (float)y1[count]);
            }

Answer : find out an (x,y) location of a point on a circle's edge C#

The radius is multiplied to the sin and cos values.

The 5 in the code comes from 2 * pi / 10 = pi / 5, for finding ten points on the circle (2 * pi in radians is 360 degrees). If you want twelve points, you use 6 instead.

Don't create Pen objects without disposing them. There are a bunch of Pen objects in the Pens class that you can use.

The -1 in the code is for flipping the coordinates around the y axis. You can put a minus sign in for the x or y coordinate depending on which order you like the coordinates along the circle.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
double r = 42.0;
 
float[] x1 = new float[12];
float[] y1 = new float[12];
 
for (int i = 0; i < 12; i++) {
   x1[i] = (float)(r * Math.Cos(i * Math.PI / 6));
   y1[i] = (float)(r * Math.Sin(i * Math.PI / 6));
}
for (int i = 0; i < 12; i++) {
   ggr.DrawLine(Pens.Black, x, y, x + x1[i], y + y1[i]);
}
Random Solutions  
 
programming4us programming4us