When approaching the rotation through angles, the yaw-pitch-roll system is probably the most intuitive. Once you know these angles, finding any vector is relatively easy.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = - (cos(pitch) * sin(roll))
z = - (cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
Show differencesHistory of post edits
#6Ignifex
Posted 07 August 2012 - 01:57 PM
When approaching the rotation through angles, the yaw-pitch-roll system is probably the most intuitive. Once you know these angles, finding any vector is relatively easy.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = (cos(pitch) * sin(roll))
z = - (cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = (cos(pitch) * sin(roll))
z = - (cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
#5Ignifex
Posted 07 August 2012 - 01:42 PM
When approaching the rotation through angles, the yaw-pitch-roll system is probably the most intuitive. Once you know these angles, finding any vector is relatively easy.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = cos(pitch) * sin(roll)
z = - (cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane right, a positive pitch goes up and a positive yaw is left.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = cos(pitch) * sin(roll)
z = - (cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane right, a positive pitch goes up and a positive yaw is left.
#4Ignifex
Posted 07 August 2012 - 01:37 PM
When approaching the rotation through angles, the yaw-pitch-roll system is probably the most intuitive. Once you know these angles, finding any vector is relatively easy.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = cos(pitch) * sin(roll)
z = -(cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = - (cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll))
y = cos(pitch) * sin(roll)
z = -(cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll))
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
#3Ignifex
Posted 07 August 2012 - 01:34 PM
When approaching the rotation through angles, the yaw-pitch-roll system is probably the most intuitive. Once you know these angles, finding any vector is relatively easy.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll)
y = cos(pitch) * sin(roll)
z = cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll)
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll)
y = cos(pitch) * sin(roll)
z = cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll)
Note that I assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up. I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left.
#2Ignifex
Posted 07 August 2012 - 01:28 PM
When approaching the rotation through angles, the yaw-pitch-roll system is probably the most intuitive. Once you know these angles, finding any vector is relatively easy.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll)
y = cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll)
z = cos(pitch) * sin(roll)
Note that I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left. I also assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up.
As you mentioned, you already have a roll angle. The yaw and pitch can then be computed from your forward vector f, using it's x, y and z components. This is a little rough and you should be careful when the x and z components are both 0, but the computation is as follows:
yaw = atan2( -x, -z )
pitch = atan2( y, sqrt( x2 + z2 ) )
Given these angles, I believe it's fastest to compute s using some rotation matrices. For yaw-pitch-roll, the rotation is applied as YPR * vector, or ZYX * v. Given a simple vector (-1, 0, 0), it's components will be:
x = cos(yaw) * sin(pitch) * sin(roll) - sin(yaw) * cos(roll)
y = cos(yaw) *cos(roll) + sin(yaw) * sin(pitch) * sin(roll)
z = cos(pitch) * sin(roll)
Note that I follow the right hand rule for the rotations, also the roll. A (small) positive roll angle turns a plane left, a positive pitch goes up and a positive yaw is also left. I also assumed you use the OpenGL eye space coordinate system, since you mentioned y is pointing up.