rotate_x Function

public function rotate_x(angle) result(r)

Uses

    • utils

rotation in the x-axis function from here

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: angle

Angle to rotate by

Return Value real(kind=wp), (4,4)


Source Code

    function rotate_x(angle) result(r)
       !! rotation in the x-axis function from [here](https://inspirnathan.com/posts/54-shadertoy-tutorial-part-8/)
        use utils, only : deg2rad
        
        !> Angle to rotate by
        real(kind=wp), intent(IN) :: angle
        
        real(kind=wp) :: r(4, 4), c, s, a

        a = deg2rad(angle)
        c = cos(a)
        s = sin(a)

        r(:, 1) = [1._wp, 0._wp, 0._wp, 0._wp]
        r(:, 2) = [0._wp, c,  -s,  0._wp]
        r(:, 3) = [0._wp, s,  c,  0._wp]
        r(:, 4) = [0._wp, 0._wp, 0._wp, 1._wp]

    end function rotate_x