RealDocs

UKismetMathLibrary::Vector_UnitCartesianToSpherical

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Converts a Cartesian unit vector into spherical coordinates on the unit sphere. Returns a 2D vector where X is Theta (polar angle, [0, PI]) and Y is Phi (azimuthal angle, [-PI, PI]).

Caveats & Gotchas

  • The input vector should be unit length — pass a normalized vector. Non-unit input will still run but the spherical output will not represent a valid point on the unit sphere.
  • Theta is the angle from the positive Z axis (colatitude), not the equatorial angle. Phi is the angle in the XY plane from the positive X axis. This convention can differ from math or physics literature that uses latitude-style definitions.

Signature

static UE_INL_API FVector2D Vector_UnitCartesianToSpherical(FVector A);

Parameters

Name Type Description Default
A FVector A unit Cartesian vector to convert.

Return Type

FVector2D

Example

Convert forward vector to spherical angles C++
FVector Dir = GetActorForwardVector(); // already unit length
FVector2D Spherical = UKismetMathLibrary::Vector_UnitCartesianToSpherical(Dir);
float ThetaDeg = FMath::RadiansToDegrees(Spherical.X);
float PhiDeg   = FMath::RadiansToDegrees(Spherical.Y);
UE_LOG(LogTemp, Log, TEXT("Theta=%.1f Phi=%.1f"), ThetaDeg, PhiDeg);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.