Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ToAngleAxis(out float, out Vector3)

Converts a rotation to angle-axis representation.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

ToAngleAxis(float, Vector3)

public void ToAngleAxis(out float angle, out Vector3 axis)

Parameters

angle

The rotation angle in degrees. The value is in the range [0, 360].

The axis of rotation as a normalized
Vector3
. If the quaternion represents no rotation, the axis defaults to
Vector3.right
.

Remarks

This method decomposes the quaternion into an angle (in degrees) and a unit vector representing the axis of rotation. Normalize the quaternion before calling this method, otherwise Unity throws an exception.

Examples

using UnityEngine;public class Example : MonoBehaviour{ void Start() { // Extracts the angle - axis from euler angle rotation Quaternion rotation = Quaternion.Euler(0, 90, 0); rotation.ToAngleAxis(out float angle, out Vector3 axis); // angle is 90 // axis is (0, 1, 0) // Extracts the angle - axis rotation from the transform rotation float transformRotationAngle = 0.0f; Vector3 transformRotationAxis = Vector3.zero; transform.rotation.ToAngleAxis(out transformRotationAngle, out transformRotationAxis); }}