# How to detect other objects are on which side of an object based on lat long

I am working on a system that detects thelat/longof vehicles. I want to track other vehicle's position: left, top-left, right, top-right, bottom-right, bottom-left etc based onlat/long.

I have used following logic to detect the bearing and direction of a vehicle:

https://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/

http://www.movable-type.co.uk/scripts/latlong.html

Using the above script, I am able to detect the direction and bearing of other vehicles but could not get their position: left, right etc.

Relative to another point, and assuming a north-oriented map:

If the longitude is less, it is to the left, if more, to the right.

If the latitude is greater, it's above it, if less, below it.

Based on the North-clockwise bearings in the first link, 0 is up, between 0 and 90 (exclusive) up-right, 90 right, > 90 - < 180 down-right, 180 down, > 180 - <270 down-left, 270 left, > 270 - <360 up-left.

Which all seems too simple, am I missing something in your question?