def update_vectors(self): "override base class" yawRadian = math.radians(self.yaw) yawCos = math.cos(yawRadian) pitchRadian = math.radians(self.pitch) pitchCos = math.cos(pitchRadian) frontX = yawCos * pitchCos frontY = math.sin(pitchRadian) frontZ = math.sin(yawRadian) * pitchCos self.front = QVector3D(frontX, frontY, frontZ) self.front.normalize() self.right = QVector3D.crossProduct(self.front, self.worldUp) self.right.normalize() self.up = QVector3D.crossProduct(self.right, self.front) self.up.normalize()
def updateCameraVectors(self): "Update the camera vectors and compute a new front" yawRadian = np.radians(self.yaw) yawCos = np.cos(yawRadian) pitchRadian = np.radians(self.pitch) pitchCos = np.cos(pitchRadian) frontX = yawCos * pitchCos frontY = np.sin(pitchRadian) frontZ = np.sin(yawRadian) * pitchCos self.front = QVector3D(frontX, frontY, frontZ) self.front.normalize() self.right = QVector3D.crossProduct(self.front, self.worldUp) self.right.normalize() self.up = QVector3D.crossProduct(self.right, self.front) self.up.normalize()
def computeFrontRightQt(yaw: float, pitch: float, worldUp=QVector3D(0.0, 1.0, 0.0)): "" yawRadian = math.radians(yaw) yawCos = math.cos(yawRadian) pitchRadian = math.radians(pitch) pitchCos = math.cos(pitchRadian) frontX = yawCos * pitchCos frontY = math.sin(pitchRadian) frontZ = math.sin(yawRadian) * pitchCos front = QVector3D(frontX, frontY, frontZ) front.normalize() right = QVector3D.crossProduct(front, worldUp) right.normalize() up = QVector3D.crossProduct(right, front) up.normalize() return (front, right, up)
def _rotation_matrix(self) -> QMatrix4x4: """ :return: A QMatrix4x4 describing the rotation from the Z axis to the cylinder's axis """ default_axis = QVector3D(0, 0, 1) desired_axis = self.axis_direction.normalized() rotate_axis = QVector3D.crossProduct(desired_axis, default_axis) rotate_radians = acos(QVector3D.dotProduct(desired_axis, default_axis)) rotate_matrix = QMatrix4x4() rotate_matrix.rotate(degrees(rotate_radians), rotate_axis) return rotate_matrix
def createRotation(self, firstPoint, nextPoint): lastPos3D = self.projectToTrackball(firstPoint).normalized() currentPos3D = self.projectToTrackball(nextPoint).normalized() angle = acos(self.clamp(QVector3D.dotProduct(currentPos3D, lastPos3D))) direction = QVector3D.crossProduct(currentPos3D, lastPos3D) return angle, direction
def _currentUp(self): return vec3d.crossProduct( self.rightVector, self.camCenter - self.camLoc ).normalized()