• 12
• 9
• 9
• 13
• 10

# Yaw, pitch and Friggin roll

This topic is 4202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all I am trying to implement a mouse behavior in java3d that is similar to plain looking around: Yaw, and pitch. Pitch works perfectly, but unfortunately the yaw is a different story. I cannot seem to adjust the yaw without getting some roll adjustment as well... I think the yaw gets applied relative to the pitch (i.e. relative to the views y-axis, not the scenes y-axis) I've tried pretty much everything mentioned in posts about this, but that dang roll keeps popping up... this is what I currently have (note the roll adjustment that makes it _almost_ right): private void adjust(float pitchIncrement, float yawIncrement){ tempRotTransform.setEuler(new Vector3d(pitchIncrement, yawIncrement, 0.5*yawIncrement)); viewTransform.mul(tempRotTransform); viewTransformGroup.setTransform(viewTransform); } Thanks in advance!

##### Share on other sites
Quote:
 Original post by the_skpHi allI am trying to implement a mouse behavior in java3d that is similar to plain looking around:Yaw, and pitch.Pitch works perfectly, but unfortunately the yaw is a different story. I cannot seem to adjust the yaw without getting some roll adjustment as well...I think the yaw gets applied relative to the pitch (i.e. relative to the views y-axis, not the scenes y-axis)I've tried pretty much everything mentioned in posts about this, but that dang roll keeps popping up... this is what I currently have (note the roll adjustment that makes it _almost_ right):private void adjust(float pitchIncrement, float yawIncrement){ tempRotTransform.setEuler(new Vector3d(pitchIncrement, yawIncrement, 0.5*yawIncrement)); viewTransform.mul(tempRotTransform); viewTransformGroup.setTransform(viewTransform);}Thanks in advance!
Your thread title made me laugh - that's how a lot of people end up feeling when working with Euler angles :-)

Anyway, it looks like you have the opposite problem of what most people have: you're using incremental rotations whereas you actually want a from-scratch rotation built from an Euler angle sequence.

Another thing I notice is that in setEuler() you seem to be submitting yaw/2 as the roll argument. What's that for?

Ultimately I think you'll want something like this:
viewTransform.setEuler(new Vector3d(pitch, yaw, 0));viewTransformGroup.setTransform(viewTransform);
Where pitch and yaw are persistent from frame to frame and are updated in response to user input. Assuming correct Euler concatenation order, this will give you pure 'mouse look' motion with no unwanted roll.