View Full Version : How to rotate a gluCylinder 3D

VanceRegnet

11-09-2005, 12:32 PM

I try to generate a 3Dpoly made of short gluCylinders, in one

dimension it works:

glRotatef(alpha, 0.0,1.0,0.0);

glTranslatef(x,y,z);

gluCylinder(quad,0.2,0.2,32,32);

But with 2 or 3 dimesion I get unexpected results.

So, please tell me: What do I have to learn ?

Vance

songho

11-09-2005, 06:42 PM

VanceRegnet,

Please describe what expected result is.

What I see in your code is;

1. Translate the cylinder to (x,y,z) first

2. then Rotate it alpha degree about Y-axis

Do you want to ratate first then translate?

If then, swap the order of your transforms.

VanceRegnet

11-10-2005, 08:59 AM

songho,

thank you for your help. I feel encouraged to describe my problem in detail.

I want to have a method that draws a steric polyline. I did it former with POVRAY, it's easier,

there you define a cylinder with a base point and a top point.

My my method is declared as following :

- void drawPolylineWithVertices; NSArray* arr

.

. ;

The related part of the definition is :

int i;

for//i=0;i< arr count-1;i++//

//

get arr objectAtindex:i

extract point array to x, y and z

calculate arcs alphaXY, alphaXZ with point i and i+1

Rotation of the cylinder at the origin

around Y-axis with alphaXZ

around Z-axis with alphaXY

then translate from the origin to x,y,z

//

I use for test three sinus functions at the three axes, you can recognize function , translate is O.K. , but the cylinders do not

point from i to i+1.

Can you see what's wrong ?

VanceRegnet

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.