0

I'm rotating a 3D object using a 4x4 transformation matrix. The object is a cylinder is rotated about its center point. The cylinder has a radius of 1 and a height of 2. Then there is a 3D vector (the position of the point on cylinder) placed at (x,y,z)=(0,1,0).

The object is rotated using Euler angles in the transformation matrix so that the object can pitch, yaw and roll. The cylinder can pitch, yaw and roll using my transformation matrix, but when applying the transformation matrix to the point the point does not move as it's supposed to.

I know that in a vertexshader file the each vertex position of the cylinder is multiplied the transformation matrix to get the world coordinates. Then the world coordinates are multiplied by the view matrix to get position relative to the camera and then multiplied by a projection matrix for the gl_position.

I tried doing the same for the point on the cylinder, to use only the transformation matrix and I tried to use transformation with the view matrix and tried with the transformation and projection, but none would work.

I want the ball to stay in its current position as shown below.

Image of pitch 45 degrees

Eagle
  • 339
  • 1
  • 3
  • 14
  • Are you trying to rotate a single vertex on the cylinder, or are you trying to rotate the cylinder around a pivot point other than the current mesh-local origin? In either case, could you provide some screenshots of what you expect and what happens now? – Ani Jun 12 '15 at 22:45
  • I'm rotating a cylinder, but i want a point (location) to be on the same spot after the rotations where is was before on the cylinder. So rotating a single vertex on a cylinder. – Eagle Jun 12 '15 at 22:51
  • Sorry, it's still unclear. A diagram or screenshot will help. – Ani Jun 12 '15 at 22:52
  • Hope this image will help – Eagle Jun 12 '15 at 23:12
  • The z on the cylinder must point towards the camera not away and in the image I applied a pitch, The cylinder can also roll and yaw. but the point goes to the wrong places when I try to use the same transformations – Eagle Jun 12 '15 at 23:27

0 Answers0