import math


def euler_from_quaternion(quaternion):
        """
        Convert a quaternion into euler angles (yaw, pitch, roll) (in radians)
        """
        x=quaternion["im"][0]
        y=quaternion["im"][1]
        z=quaternion["im"][2]
        w=quaternion["re"]

        t0 = 2*(w*z + x*y)
        t1 = 1 - 2 * (x*x + y*y)
        t1 = w*w + x*x - y*y - z*z 
        yaw = math.atan2(t0, t1)
     
        t2 = 2*(w*y - z*x)
        pitch = math.asin(t2)
     
        t3 = 2*(w*x + y*z)
        t4 = w*w - x*x - y*y + z*z 
        roll = math.atan2(t3, t4)
     
        return yaw, pitch, roll