MCPcopy Create free account
hub / github.com/ICE27182/Python-3D-renderer / get_rotation_mat

Method get_rotation_mat

pyrender.py:809–891  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

807
808
809 def get_rotation_mat(self) -> tuple:
810 yaw = -(self.yaw - 90) * pi / 180
811 pitch = -self.pitch * pi / 180
812 roll = self.roll * pi / 180
813 sin_yaw = sin(yaw)
814 cos_yaw = cos(yaw)
815 sin_pitch = sin(pitch)
816 cos_pitch = cos(pitch)
817 sin_roll = sin(roll)
818 cos_roll = cos(roll)
819
820 rotation = (
821 (cos_roll, -sin_roll, 0,),
822 (sin_roll, cos_roll, 0,),
823 (0, 0, 1),
824 )
825
826 rot = (
827 (1, 0, 0,),
828 (0, cos_pitch, -sin_pitch,),
829 (0, sin_pitch, cos_pitch,),
830 )
831
832 rotation = (
833 (rotation[0][0], rotation[0][1] * rot[1][1] + rotation[0][2] * rot[1][2], rotation[0][1] * rot[2][1] + rotation[0][2] * rot[2][2],),
834 (rotation[1][0], rotation[1][1] * rot[1][1] + rotation[1][2] * rot[1][2], rotation[1][1] * rot[2][1] + rotation[1][2] * rot[2][2],),
835 (rotation[2][0], rotation[2][1] * rot[1][1] + rotation[2][2] * rot[1][2], rotation[2][1] * rot[2][1] + rotation[2][2] * rot[2][2],),
836 )
837
838 rot = (
839 (cos_yaw, 0, sin_yaw,),
840 (0, 1, 0,),
841 (-sin_yaw, 0, cos_yaw,),
842 )
843
844 rotation = (
845 (rotation[0][0] * rot[0][0] + rotation[0][2] * rot[0][2], rotation[0][1], rotation[0][0] * rot[2][0] + rotation[0][2] * rot[2][2],),
846 (rotation[1][0] * rot[0][0] + rotation[1][2] * rot[0][2], rotation[1][1], rotation[1][0] * rot[2][0] + rotation[1][2] * rot[2][2],),
847 (rotation[2][0] * rot[0][0] + rotation[2][2] * rot[0][2], rotation[2][1], rotation[2][0] * rot[2][0] + rotation[2][2] * rot[2][2],),
848 )
849 return rotation
850
851 yaw = self.yaw * pi / 180
852 pitch = self.pitch * pi / 180
853 sin_yaw = sin(yaw)
854 cos_yaw = cos(yaw)
855 sin_pitch = sin(pitch)
856 cos_pitch = cos(pitch)
857 if self.roll == 0:
858 return ((sin_yaw, 0, -cos_yaw,),
859 (-sin_pitch * cos_yaw, cos_pitch, -sin_pitch * sin_yaw),
860 (cos_yaw * cos_pitch, sin_pitch, sin_yaw * cos_pitch,))
861 else:
862 roll = self.roll * pi / 180
863 sin_roll = sin(roll)
864 cos_roll = cos(roll)
865 # rotation = (
866 # (cos_roll, -sin_roll, 0),

Callers 4

__init__Method · 0.95
rotateMethod · 0.95
pymain.pyFile · 0.80
prefinal.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected