Last active
July 1, 2024 15:38
-
-
Save hotohoto/1d37ce63bb3c3a0d7e37447c96ffdf9c to your computer and use it in GitHub Desktop.
Rotate an object by setting yaw pitch roll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import mathutils | |
import math | |
# blender rotate in the right hand direction | |
figher = bpy.context.scene.objects['airplane'] | |
figher.location = (0, 0, 0) | |
figher.rotation_euler = (0, 0, 0) | |
yaw = math.radians(190) | |
pitch = - math.radians(-50) | |
roll = math.radians(10) | |
matrix_yaw = mathutils.Matrix.Rotation(yaw, 4, 'Z') | |
matrix_pitch = mathutils.Matrix.Rotation(pitch, 4, 'Y') | |
matrix_roll = mathutils.Matrix.Rotation(roll, 4, 'X') | |
figher.rotation_euler = (matrix_yaw @ matrix_pitch @ matrix_roll).to_euler() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment