Dear All,

I’ve been tasked with drawing lots of pipes. Exciting I know. Basicly I’m being passed an array of points, and I draw the pipes based of those, treating each point as an end point of a pipe. I’m using an instance of a cylinder to do this, and my problem is in creating the matrix for each instance. Basicly I cant figure out why my rotation angles are not turning out right. I basicly need an XY and a YZ rotation angle, which I generate in the following manner :

```
TempPipePoint.x = (Temp1->x + Temp2->x)/2;
TempPipePoint.y = (Temp1->y + Temp2->y)/2;
TempPipePoint.z = (Temp1->z + Temp2->z)/2;
float fDx = Temp2->x - Temp1->x;
float fDy = Temp2->y - Temp1->y;
float fDz = Temp2->z - Temp1->z;
TempPipePoint.anglexy = atan2( (fDy), (fDx) ) ;
TempPipePoint.angleyz = -atan2( (fDz), (fDy) ) ;
TempPipePoint.length = sqrt( (fDx) * (fDx) + (fDy) * (fDy) + (fDz) * (fDz) );
TempPipePoint.isnop = false;
m_PipeList.push_back(TempPipePoint);
m_iNumberOfPipes++;
```

…

Then I create the matrix as below :

RotX[0] = cos(xyrot );

RotX[1] = -sin(xyrot );

RotX[4] = sin(xyrot);

RotX[5] = cos(xyrot );

RotY[5] = cos(yzrot );

RotY[6] = -sin(yzrot );

RotY[9] = sin(yzrot );

RotY[10] = cos(yzrot );

TempRotationMatrix *= RotX;

TempRotationMatrix *= RotY; // Seperated For debugging, instead of building the entire matrix at once.

This works as I would expect if the pipe points are all on the XY plane, but if I vary the Z cordinates the thing goes haywire, with the exception that it works ok for a pipe that has an end point on the origin, which is a bit odd. Does anyone have an idea what I’m doing wrong?

Regards,

Jesse