# Rotation around custom axis with Quarternions

I am trying to set up a pitch yaw roll style rotation for a programming project. Currently, I'm rotating defining each axis of rotation as:

Yaw Axis   = (0,0,1)
Pitch Axis = (0,1,0)
Roll Axis  = (1,0,0)


My issue is that when the object 'rolls' it should then pitch in the axis relative to it's new rotation, however as I'm always defining the axis for pitch as (0,1,0) it always pitches up or down, regardless of orientation. How do I calculate the axis that is perpendicular to my objects new rotation?

Cheers! Kaine

• roll your three axes at the same time when you are rolling the object – Brian Cheung Sep 6 '15 at 14:53
• I managed to get it kind of working when trying that method, for example I had Pitch Axis = (0, cos(roll), sin(roll)) which works if you roll then pitch. However, if I pitch upwards, then roll, because the pitch axis is dependent on the roll, it not only rolls but it also rotates as the Pitch Axis is changing, I can't figure out the relationship between all three to make this work... any ideas? – Kaine van Gemert Sep 7 '15 at 11:02
• I think that the pitch axis only depends on the 'old' roll axis, not on the 'new' roll axis. That is, each time when you want to do 'sth', you have to do 'Yaw = sth(Yaw); Pitch = sth(Pitch); Roll = sth(Roll); object = sth(object)' where '=' here means 'assigning value', not 'equal'. – Brian Cheung Sep 7 '15 at 11:23
• Thanks for the reply! I'll certainly give this a go, just like to clarify.. what do you mean by sth? Cheers! – Kaine van Gemert Sep 7 '15 at 15:59
• Sth means any single rotation action by any degree, for example "Yaw 30 degrees" or "Roll 90 degrees". Cheers! =D – Brian Cheung Sep 7 '15 at 16:06