• 14
• 12
• 9
• 10
• 13

# How to make a curved arrow? (Curved cylinder)

This topic is 2808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello everyone,
I want to make a curved arrows, as in these photos:

I believe that the arrow can be broken down into a body (curved cylinder) and a head (a cone with a right orientation).

1) Body:
I have done research and I discovered that everyone says to make the curved cylinder with a torus. The problem is that I need only a part of the torus. I found the source code of the function glutSolidTorus(), but I could not change them to draw a part of torus. I hope some of you can help me.

void Torus(GLfloat r, GLfloat R, GLint nsides, GLint rings){  int i, j;  GLfloat theta, phi, theta1;  GLfloat cosTheta, sinTheta;  GLfloat cosTheta1, sinTheta1;  GLfloat ringDelta, sideDelta;  ringDelta = 2.0 * M_PI / rings;  sideDelta = 2.0 * M_PI / nsides;  theta = 0.0;  cosTheta = 1.0;  sinTheta = 0.0;  for (i = rings - 1; i >= 0; i--) {    theta1 = theta + ringDelta;    cosTheta1 = cos(theta1);    sinTheta1 = sin(theta1);    glBegin(GL_QUAD_STRIP);    phi = 0.0;    for (j = nsides; j >= 0; j--) {        GLfloat cosPhi, sinPhi, dist;        //	phi += sideDelta;	cosPhi = cos(phi);	sinPhi = sin(phi);	dist = R + r * cosPhi;	//	glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi   );	glVertex3f(cosTheta1 * dist,   -sinTheta1 * dist,   sinPhi *r);	glNormal3f(cosTheta  * cosPhi, -sinTheta  * cosPhi, sinPhi   );	glVertex3f(cosTheta  * dist,   -sinTheta  * dist,   sinPhi *r);    }    glEnd();    theta = theta1;    cosTheta = cosTheta1;    sinTheta = sinTheta1;  }}

How do I find the right orientation for the cone? As this depends on the torus?

Thank you all, bye.

##### Share on other sites
For the "body" of the arrow:

You have a complete solution in front of you and you can't do anything with it?

Seriously, why do people refuse to make efforts to solve problems for their own? (apart from some googling and asking on forums)

You (in general) will never be programmers this way.

##### Share on other sites
You have a method of creating a full torus. Read through the maths in your code sample and try to fully understand what is happening. Once you understand it you will see how to create what you want which is basically a part of a torus from angle A to angle B.

You'll need paper and a pencil, start sketching and get your old trigonometry books out.

##### Share on other sites
Quote:
 Original post by DargYou have a method of creating a full torus. Read through the maths in your code sample and try to fully understand what is happening. Once you understand it you will see how to create what you want which is basically a part of a torus from angle A to angle B.You'll need paper and a pencil, start sketching and get your old trigonometry books out.

I haven't taken a look at the code in much detail, but as far I see, there's one single variable to change that would do the thing. And some adjustments to position the thing the way the OP wants.
The variable names are quite self explaining, so...

##### Share on other sites
Well okay if you think we should spoil the fun of learning the maths himself then personally I'd change this line:

ringDelta = 2.0 * M_PI / rings;

to:

where angleInRadians is the amount of the circle you want the curve to go around.

After that it's just a matter of rotating and positioning the object right.

##### Share on other sites
Quote:
 Original post by DargWell okay if you think we should spoil the fun of learning the maths himself then personally I'd change this line:ringDelta = 2.0 * M_PI / rings;to:ringDelta = angleInRadians / rings;where angleInRadians is the amount of the circle you want the curve to go around.After that it's just a matter of rotating and positioning the object right.

Nooo, you are teh real spoiler!!1!!11

##### Share on other sites
Quote:
 Original post by szecsNooo, you are teh real spoiler!!1!!11

Sorry :(