Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My question is in about rotate methods in android.graphics.Camera. In Docs, I saw these comments:

public void rotateX (float deg) Since: API Level 1
Applies a rotation transform around the X axis.

public void rotate (float x, float y, float z) Since: API Level 12
Applies a rotation transform around all three axis.

There is my question:What is difference between using rotate (float x, float y, float z) and a sequence of rotate methods? For example what's the difference between these two snippets A and B?

A)

camera.rotate (x, y, z);

B)

camera.rotateX (x);
camera.rotateY (y);
camera.rotateZ (z);
share|improve this question
2  
They're probably identical. Have you run a test to try it out? –  Tetrad Jan 13 '13 at 7:34
    
@Tetrad Really,my question is:"Is there any difference between ...",yes the result seems to be identical,but I,m not sure.Also,if those are identical,why there are different methods to do the same with identical result? –  Student Student Jan 13 '13 at 7:55
add comment

1 Answer 1

Applying a sequence of Euler (yaw/pitch/roll) rotations can have a disadvantage when compared to applying a rotation matrix or quaternion operation, which both apply the rotations simultaneously. Sequential axis transforms have the potential to suffer from gimbal lock when one step in their sequence renders a subsequent rotation meaningless. I.e., this problem would occur if the first rotation moves the vector directly onto the axis of the second rotation, then the second rotation accomplishes nothing. The more complex operations are immune to this problem.

Presumably, the API 12 method public void rotate (float x, float y, float z) is an advanced matrix or quaternion rotation. However, if it was naively implemented, it may be no better than applying the rotations in sequence. In that case, its only benefit would be reducing the number of functions you would need to call. But if it IS implemented well, then it will be faster, simpler to use, and less error prone than sequential operations.

In either case, you should use it for 3-axis rotations.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.