math - How to find the azimuth/elevation from a vehicle to a target? -


i trying find out how compute azimuth , elevation angles moving air-vehicle simulation point on ground.

i have vehicle's position vector p, , orientation quaternion vehq. have target position t, , have built difference vector dpt subtracting p t.

how go computing az/el angles target? can guess, not familiar 3d math, helpful explanation wonderful.

thanks

first, find relative position vector dpt vehicle target:

worldspace target vector dpt = t - p 

since vehicle position p , target position t in world coordinates, resulting vector dpt represented in world coordinates. so, must use vehicle orientation quaternion rotate dpt world coordinates vehicle coordinates. correct way depends on conventions used whatever generated quaternion, math 1 of following:

vehicle target vector u = vector_part( vehq * quaternion(0,dpt) * conjugate(vehq) )                  or                       u = vector_part( conjugate(vehq) * quaternion(0,dpt) * vehq ) 

since have provided no information on quaternion convention, have no way know 1 of these correct application. however, highly quaternion source provides functions or methods using quaternions rotate vectors. so, should locate these functions, read documentation, , try using them before rolling own.

once have target vector in vehicular coordinates, can use standard formulas finding azimuth , elevation angles. depends on coordinate conventions, example, if coordinate convention right-handed z-axis "up" direction:

azimuth = atan2(u.y, u.x) elevation = atan2(u.z, sqrt(u.x^2 + u.y^2)) 

this should calculate elevation in radians ranging -pi/2 +pi/2, , azimuth in radians ranging -pi +pi, 0 along +x axis, , increasing counterclockwise (as long elevation not vertical...).


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -