Skip to content

Instantly share code, notes, and snippets.

@hotohoto
Last active July 1, 2024 15:38
Show Gist options
  • Save hotohoto/1d37ce63bb3c3a0d7e37447c96ffdf9c to your computer and use it in GitHub Desktop.
Save hotohoto/1d37ce63bb3c3a0d7e37447c96ffdf9c to your computer and use it in GitHub Desktop.

Revisions

  1. hotohoto revised this gist May 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rotate_yaw_pitch_roll.py
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@

    # blender rotate in the right hand direction

    figher = bpy.context.scene.objects['fighter']
    figher = bpy.context.scene.objects['airplane']

    figher.location = (0, 0, 0)
    figher.rotation_euler = (0, 0, 0)
  2. hotohoto revised this gist May 11, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions rotate_yaw_pitch_roll.py
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@
    import mathutils
    import math

    # blender rotate in the right hand direction

    figher = bpy.context.scene.objects['fighter']

    figher.location = (0, 0, 0)
  3. hotohoto revised this gist May 11, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rotate_yaw_pitch_roll.py
    Original file line number Diff line number Diff line change
    @@ -15,4 +15,4 @@
    matrix_pitch = mathutils.Matrix.Rotation(pitch, 4, 'Y')
    matrix_roll = mathutils.Matrix.Rotation(roll, 4, 'X')

    figher.matrix_world = matrix_yaw @ matrix_pitch @ matrix_roll
    figher.rotation_euler = (matrix_yaw @ matrix_pitch @ matrix_roll).to_euler()
  4. hotohoto created this gist May 11, 2024.
    18 changes: 18 additions & 0 deletions rotate_yaw_pitch_roll.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import bpy
    import mathutils
    import math

    figher = bpy.context.scene.objects['fighter']

    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.matrix_world = matrix_yaw @ matrix_pitch @ matrix_roll