Public Group

# Cylinder end points

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

## Recommended Posts

Dear almighty oracles of Game Development, I ask that you spare but a brief moment to help me, the lowly noob that I am. What I'm trying to do is really simple. I am trying to build an animated stick figure in opengl using just cylinders and spheres. But I have a problem. When you draw a cylinder in opengl you only specify the length and starting point. Is there any function that I can call to find out where it ends up? Or is there perhaps some other method? I know it's probably a very simple answer, but I cant find it anywhere. I have gone through all of the nehe tutorials, all of the gametutorials.com opengl tutorials, searched through numerous places on the internet, and gone through pretty much the entire opengl red book and blue book with no success. If you can help me, it would be greatly appreciated. This is driving me crazy.

##### Share on other sites
I'm assuming you're using the function gluCylinder, never really used glut myself, but here's the entry from the redbook on it.
Quote:
 From the Redbook, p. 329void gluCylinder (GLUquadricObj *qobj, GLdouble baseRadius, GLdouble topRadius, GLdouble height, GLint slices, GLint stacks);Draws a cylinder oriented along the z axis, with the base of the cylinder at z = 0 and the top at z = height. Like a sphere, the cylinder is subdivided around the z axis into a number of slices and along the z axis into a number of stacks. baseRadius is the radius of the cylinder at z = 0. topRadius is the radius of the cylinder at z = height. If topRadius is set to zero, then a cone is generated.

On second thought, it doesn't sound like you're using this one, as this generates a cylinder object, but doesn't render it :/

##### Share on other sites
First of all, the object is created and defined in object space. So, where it ends up in your scene or world depends entirely on the world matrix you set before rendering it.

In object space, I presume the starting point plus the length gives you the end point. For example, if the cylinder is by default defined along the x-axis, the end point will be startingpoint.x + length. Otherwise, the cylinder might be centered around the starting point, leading to startingpoint.x +/- length/2.

That is, if I didn't miss anything obvious.

Illco

PS: replace x with z according to above posting.

##### Share on other sites
Starting point coordinate + length + direction = end point. How is direction stored?

I haven't used OpenGL before, and I suspect neither did many who are reading this. Therefore, please specify the format in which this data is stored in terms of mathematical symbols instead of API.

By the way, your join date is my birthday [cool]

##### Share on other sites
Quote:
 Starting point coordinate + length + direction = end point. How is direction stored?

That would be start + (length * direction) = end with length being a scalar and direction a unit vector. In this case the z-axis i.e. (0,0,1). In general with Cartesian directions you can omit the vector notation and simply use the corresponding elements (z in this case).

I did use OpenGL before but that's a few years back.

##### Share on other sites
Yup, gluCylinder(quad, basRadius, topRadius, height, sl, st) is the way I'm using it. Working qith quadrics seems to be the only way of doing things.
Basically, it seems that you tell the quadric it's location rotation etc (glTranslate, glRotate) then you tell it what to draw. Ie sphere, disc or cylinder. (Correct me if I'm wrong)

But, as it only takes in the height(length) of the cylinder, it means that the end point must be equated somewhere so that it can be rendered. If this is the case, shouldn't I then be able to access this somewhere? And wouldn't my working it out manually mean that the computer is actually working it out twice thereby affecting performance?

v0dKA: Woah, what a coincidence. This must mean that you were destined to be in this thread...

##### Share on other sites
Ok, from further searching, it looks like I'm going to have to work it out each time. But its been a while since I've done trig... Does this look right?

Assuming:
               /|      / |     /  |  h /   |   /    | o  /     | / m    |/-------|    a

Where m is the angle and h is the length of the hypotenuse, it should just be (x + cos(m)*d, y + sin(m)*d) for the end coordinates right?

[Edited by - Fruny on January 22, 2006 5:41:35 PM]

1. 1
2. 2
3. 3
Rutin
20
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633655
• Total Posts
3013179
×