Documentation

Unity Engine

Download Unity

Unity Engine

angle

Returns the angle in radians between two float2 vectors.
Read time 3 minutesLast updated 5 days ago

Definition

angle(float2, float2)

Returns the angle in radians between two float2 vectors.
public static float angle(float2 a, float2 b)

Parameters

The first vector.

The second vector.

Returns

Type

Description

floatThe angle between the two vectors in radians, in the range 0 to PI.

Remarks

The vectors don't need to be unit length. Returns zero if either vector is zero length or not finite, or if its squared length overflows, which happens for components larger than about 1e19 in magnitude. Components smaller than about 1e-19 in magnitude lose precision as the squared length underflows.

angle(float3, float3)

Returns the angle in radians between two float3 vectors.
public static float angle(float3 a, float3 b)

Parameters

The first vector.

The second vector.

Returns

Type

Description

floatThe angle between the two vectors in radians, in the range 0 to PI.

Remarks

The vectors don't need to be unit length. Returns zero if either vector is zero length or not finite, or if its squared length overflows, which happens for components larger than about 1e19 in magnitude. Components smaller than about 1e-19 in magnitude lose precision as the squared length underflows.

angle(double2, double2)

Returns the angle in radians between two double2 vectors.
public static double angle(double2 a, double2 b)

Parameters

The first vector.

The second vector.

Returns

Type

Description

doubleThe angle between the two vectors in radians, in the range 0 to PI.

Remarks

The vectors don't need to be unit length. Returns zero if either vector is zero length or not finite, or if its squared length overflows, which happens for components larger than about 1e154 in magnitude. Components smaller than about 1e-154 in magnitude lose precision as the squared length underflows.

angle(double3, double3)

Returns the angle in radians between two double3 vectors.
public static double angle(double3 a, double3 b)

Parameters

The first vector.

The second vector.

Returns

Type

Description

doubleThe angle between the two vectors in radians, in the range 0 to PI.

Remarks

The vectors don't need to be unit length. Returns zero if either vector is zero length or not finite, or if its squared length overflows, which happens for components larger than about 1e154 in magnitude. Components smaller than about 1e-154 in magnitude lose precision as the squared length underflows.

angle(quaternion, quaternion)

Returns the angle in radians between two unit quaternions.
public static float angle(quaternion q1, quaternion q2)

Parameters

The first quaternion.

The second quaternion.

Returns

Type

Description

floatThe angle between two unit quaternions.

angle(quaternion)

Returns the angle in radians that a unit quaternion rotates by.
public static float angle(quaternion q)

Parameters

The unit quaternion.

Returns

Type

Description

floatThe rotation angle of the input quaternion, in radians.

Remarks

The result is the angle of the axis-angle representation of q, in the range 0 to 2 * PI. Use math.axis to get the corresponding rotation axis. Because w is close to 1 for small rotations, angles smaller than about 5e-4 radians (0.03 degrees) return zero. For better precision near zero, use math.angle with quaternion.identity.