@@ -354,7 +354,23 @@ def convertRotationFromCV2GL(self, rotation):
354354 U = M * quaternion * M
355355
356356 return U .toEulerAngles ()
357-
357+
358+ @Slot (QVector3D , QVector3D , float , float , result = QVector3D )
359+ def getRotatedCameraViewVector (self , camereViewVector , cameraUpVector , pitch , yaw ):
360+ """ Compute the rotated camera view vector with given pitch and yaw (in degrees).
361+ Args:
362+ camereViewVector (QVector3D): Camera view vector, the displacement from the camera position to its target
363+ cameraUpVector (QVector3D): Camera up vector, the direction the top of the camera is facing
364+ pitch (float): Rotation pitch (in degrees)
365+ yaw (float): Rotation yaw (in degrees)
366+ Returns:
367+ QVector3D: rotated camera view vector
368+ """
369+ cameraSideVector = QVector3D .crossProduct (camereViewVector , cameraUpVector )
370+ yawRot = QQuaternion .fromAxisAndAngle (cameraUpVector , yaw )
371+ pitchRot = QQuaternion .fromAxisAndAngle (cameraSideVector , pitch )
372+ return (yawRot * pitchRot ).rotatedVector (camereViewVector )
373+
358374 @Slot (QVector3D , QMatrix4x4 , Qt3DRender .QCamera , QSize , result = float )
359375 def computeScaleUnitFromModelMatrix (self , axis , modelMat , camera , windowSize ):
360376 """ Compute the length of the screen projected vector axis unit transformed by the model matrix.
0 commit comments