Unity rotation: Euler and Quaternion
Convert Euler angles to a Quaternion and back the way Unity does, with C#.
- Category
- SCP:SL, Steam and Unity
- Price
- free
The tool starts in your browser.
Everything is calculated in your browser. Nothing you type is sent to our server.
How to use it in three steps
The tool as a schematic with this page's example. Each step's number stands where you take it: in the fields, at the result or outside the tool.
Enter Euler angles or quaternion components.
See the other form and an axis preview.
Copy the ready C# line.
A 90 degree turn around Y as a quaternion
Unity stores a rotation as a quaternion and shows Euler angles in the inspector. The tool computes one from the other in Unity's axis order. The result is computed by the same function the tool at the top of the page uses, every time the page is shown.
Euler angles
- X
- 0 degrees
- Y
- 90 degrees
- Z
- 0 degrees
Half the angle
- cos 45
- 0.7071
- sin 45
- 0.7071
A quaternion takes the sine and cosine of half the angle: 90 degrees gives 45.
Quaternion
- new Quaternion
- new Quaternion(0f, 0.7071f, 0f, 0.7071f)
A turn around Y alone leaves the y and w components, with x and z at zero.
The object's directions
- transform.forward
- (1, 0, 0)
- transform.right
- (0, 0, -1)
The forward and right vectors after the turn show where the object faces.
C#
Quaternion.Euler(0f, 90f, 0f)new Quaternion(0f, 0.7071f, 0f, 0.7071f)new Vector3(0f, 90f, 0f)
Questions
Related tools
The tool does one job. If the same thing should happen automatically in your bot, server or system, we build it.
Missing a tool you need?
Tell us what you want to calculate or generate. We will tell you whether a tool is enough or an integration in your system fits better.