Jump to content
  • Advertisement
Sign in to follow this  
bhodi78

How to make a curved arrow? (Curved cylinder)

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

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;
}
}



2) Head:
How do I find the right orientation for the cone? As this depends on the torus?

Thank you all, bye.

Share this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Darg
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.


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 this post


Link to post
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:

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.

Share this post


Link to post
Share on other sites
Quote:
Original post by Darg
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:

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 this post


Link to post
Share on other sites
Quote:
Original post by szecs
Nooo, you are teh real spoiler!!1!!11


Sorry :(

Share this post


Link to post
Share on other sites
Hello,
I thank you all for your valuable advice that you gave me.
A special thanks goes to Darg. :-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!