GetAzimuthAndElevation(...)

Hello everyone and Happy New year !

I’m encountering a problem at the moment. Assume you have a grid, projected in 2D space within the 3D world with some length. (for example a grid of 32 clusters)
I’m trying to sort out thoses clusters to find, for a specific cluster, which are the nearest clusters in 4 directions (left-right-up-down). I obtained by using a line trace the cluster which is “selected”, and the grid array corresponding to all clusters in the grid. So to sort out positions of those clusters, I’m assuming I can do it by checking their position from a point (I’m using the world origin), and checking how they are elevate and left or right from that origin. That’s here that I try to use the function FMath::GetAzimuthAndElevation().

But I’m having a lot of troubles to use it. I don’t understand how to use it correctly. What it needs to works fine as what I’m trying isn’t giving any good results. Does anyone knows how to use it correctly?

I hope I’m explaining well what is my problem as I’m not native in english :p…

Have a nice day guys !

RESOLVED :

To use FMath::GetAzimuthAndElevation method, you first need to define vectors that are the base axis used to calculate it. In my example I wanted to take the Elevation and Azimuth of an actor from the origin of the world (coordinates 0,0,0), this following code works well :wink: :

const FVector AxisX = FVector::ForwardVector;
const FVector AxisY = FVector::RightVector;
const FVector AxisZ = FVector::UpVector;

FVector DirectionToOrigin = Cluster->GetActorLocation() - FVector(0, 0, 0);
					DirectionToOrigin.Normalize();
FVector2D AzimuthAndElevationFromOrigin = FMath::GetAzimuthAndElevation(DirectionToOrigin, AxisX, AxisY, AxisZ);