# X, Y, Z rotation around camera

I'm making a 3d orthogonal-projected, game using painters' algorithm in java.

I'm able to rotate the objects with incremental rotations (e.g. rotate all objects 10 degrees) using affine transformations, but that involves changing/saving the rotated positions of the objects.

I want be able to rotate using a viewing direction vector. What is the maths and/or java code to do this?

Assume the default viewing direction (no rotation needed) would be (0,0,1) (looking down the z axis).

I can elaborate and/or clarify if wanted.

EDIT: What I'm doing currently:

for all drawable things:

// using transform matrices (translate to origin, rotate around origin, translate back)

rotate around center by x,y,z radians

What I want:

for all drawable things:

rotate around center using viewing direction (vector)

• How do you rotate and draw your objects right now? Give us some code. – kolenda Sep 22 '14 at 12:05
• It sounds like you might be referring to billboarding where all objects face the camera no matter where the camera moves to. Is that correct? – Steve H Sep 22 '14 at 14:29
• @SteveH I have some objects which billboard (they're images that always face the viewer), others that don't. – Will Hardwick-Smith Sep 22 '14 at 22:32
• If you're willing to do a bit of learning, read up on quaternions (en.wikipedia.org/wiki/Quaternions_and_spatial_rotation). It might be more helpful to google it in relation to game development – Aralox Sep 23 '14 at 3:44
• OK thanks, I may use these if I can figure out how to use them. Is it possible to do this with affine transformation matrices? – Will Hardwick-Smith Sep 23 '14 at 6:24