# Rotate by pre-existing transformation matrix

I am trying to draw cylinders with their axis along a specific line in 3space, call it vector = <x,y,z>. I have come up with an ofMatrix3x3 that is the suitable transformation matrix, call it matrix R, that would be able to transform the “world” matrix so that the vertical axis is now my given vector.

I can’t seem to find a way using ofRotate or ofTranslate to feed it my matrix I created, R, and tell the world to apply that transformation matrix to the current state.

There are two solutions I can see to this problem, input is welcome on either!

1. Is there a way to tell the world matrix to rotate/translate to a specific vector, i.e. send <0,0,1> to <x,y,z>?

2. If not, I have come up with the appropriate transformation matrix, ofMatrix3x3 (call it R), how can I say something like ofRotate(by matrix R), rotating the unit vector <0,0,1> by applying R?

ofMultMatrix?

Thanks, but I believe that function just does matrix multiplication. I want to use a transformation matrix to rotate the world.

Yes it muliplies but against internal projection matrix or the others depends on ofMatrixMode.

See GLRender for example.

Are you creating the geometry by yourself positioning the vertices one by one or are you using `ofCylinderPrimitive`?