# Thread: Texture on a disk

1. ## Texture on a disk

I have defined a disk with a triangle fan and I want to put a texture on it. Unfortunately, I can't figure out how to define the texture coordinates.

Can anyone help me?

Thanks in advance for the time you will spend trying to help me.

2. It depends on how you want to texture. Do you want to drap a square raster over the circle?

3. Originally Posted by tonyo_au
It depends on how you want to texture. Do you want to drap a square raster over the circle?
My texture image represents a circular picture and I want this circular area to be drawn on the surface of my disk. Let's say I want to put the texture on both faces of a coin.

4. Then the center of your disk has UV if 0.5,0.5 and the other vertices lie on a circle where the vertex (radius,0,0) maps to UV (1,0.)

5. Originally Posted by tonyo_au
Then the center of your disk has UV if 0.5,0.5 and the other vertices lie on a circle where the vertex (radius,0,0) maps to UV (1,0.)

My disk is made of n triangles, and triangle i has the center of the disk as the first vertex, (radius*cos((i-1)*a),radius*sin((i-1)a)) as second vertex and (radius*cos(i*a),radius*sin(i*a)) for third vertex. Can you please explicitely tell me what the texture coordinates should be to have the disk drawn in my texture image to be pasted over my 3D disk?

6. If my maths is right, the each vertex the uv will be( (cos((i-1)*a)+1)/2, (sin((i-1)a)+1)/2)

7. Then your math is wrong...

8. I don't think so
Code :
```  double a = DEGREES2RADIANS(45);

float ox = 200;
float oy = 200;
float r = 100;

glBegin(GL_TRIANGLE_FAN);
glColor3f(0.5,.5f,0.0f);
glVertex3f(ox,oy,0);

for (int i = 0; i < 7; i++)
{
float u = (float(cos((i-1)*a))+1.0)/2.0;
float v = (float(sin((i-1)*a))+1.0)/2.0;
float cx = float(cos((i-1)*a)) * r;
float cy = float(sin((i-1)*a))* r;
glColor3f(u,v,0);
glVertex3f(cx+ox,cy+oy,0);
}
glEnd();```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•