Help in making polygon sharing a common edge

if we change the value of n=1,2,3,4…n the vertics should b drwan and make a polygon of that no. of vertics

Please don’t use cell phone notation. I value the the letter ‘e’.

So what are you trying to do? You want to make a polygon that shares a common edge? With what? Another polygon?

You’re saying, you want a function that takes a integer n and outputs a polygon with that number of vertices? That’s easy enough.


glBegin(GL_POLYGON);
for (int i = 0; i < n; i++)
   glVertex3f(0,0,0);
glEnd();

Done! Of course this is pretty worthless. What are you trying to do? You need to define a problem. For example, if n is one or two, what kind of polygon would you expect to get? A polygon is planar and you can’t make a plane without at least three points.

Is this supposed to converge on some shape? Should n=3 be a equilateral triangle? n=4 be a square? Should n=1000 look like a nicely-rounded circle?

question is that we change value of vertices
3,4,5,6…n
then on the same vertics triangle ,then 4gon then pentagon then hexagon is drawn but on same vertics

i have tried this but itz not working window is drwan but then no shape is drawn

just like this


i hope u will understand my question

That’s a much better question and the picture always helps.

As I thought, your shape is going to converge on a circle. Without giving too much code, you basically have a set a of vertices and you need to figure out where to place them.

If you think about this problem in polar coordinates, imagine you want to draw a circle with 3 points (a triangle). Well, you know you’re going to need 120 degrees between each direction for each vertex. If I put one vertex on the (1,0) axis, then the next point is going to be 120 degrees rotated around and the next point will be another 120 degrees.

Doing the same thing with 4 points, you will have 90 degrees between each point. You see the pattern…

degrees per vertex = 360 degrees / n vertices