Okay, so I’ve been trying to wrap my head around this, but the more I think about it, the more I get a headache. Even using https://eater.net/quaternions/video/intro to help me it’s still difficult. Making the camera move up and down and around, or in other words pitch and turn, is a rather simple matter, but trying to make the camera turn after raising the camera, aka turning it about the i axis and then about some other axis, results in movement I don’t want. Heres the relevant code I have so far.
if amount_turn_will_change != 0 and amount_pitch_will_change != 0: total_degrees = sqrt(self.turn_radians ** 2 + self.pitch_radians ** 2) elif amount_pitch_will_change != 0: if self.pitch_radians != pi: self.pitch = (-sin(self.pitch_radians % pi / 2)) self.__past_pitch = self.pitch else: self.pitch = -sin(pi / 2) self.__past_pitch = self.pitch real_compontent = cos(self.pitch_radians / 2) if self.__past_turn != 0: self.quaternion = (real_compontent, 1 * self.pitch, 0, self.__past_turn * self.pitch) else: self.quaternion = (real_compontent, 1 * self.pitch, 0, 0) elif amount_turn_will_change != 0: self.turn = (sin(self.turn_radians / 2)) self.__past_turn = self.turn real_compontent = cos(self.turn_radians / 2) if self.__past_pitch != 0: i_coefficient = 1 - self.__past_pitch k_coefficient = self.__past_pitch pitch = k_coefficient * self.turn turn = i_coefficient * self.turn self.quaternion = (real_compontent, pitch, 0, turn) else: self.quaternion = (real_compontent, 0, 0, 1 * self.turn)
If anyone has any suggestions as to how I can move forward I greatly appreciate them.