I have two objects, A and B, each of them has a set of coordinates (x,y). How do I understand where is A in relation to B's position?
If I where to just check each coordinates I could do it like this:
B(x:5,y:5), A(x:4,y:5); x = 5-4 = 1; y = 5-5 = 0; A it's on the left
B(x:5,y:5), A(x:6,y:5); x = 5-6 = -1; y = 5-5 = 0; A it's on the right
B(x:5,y:5), A(x:5,y:6); x = 5-5 = 0; y = 5-6 = -1; A it's on top of B
B(x:5,y:5), A(x:6,y:5); x = 5-5 = 0; y = 5-4 = 1; A it's under B
But I was wondering, since I'm using a standard Vector2 data structure (from LibGDX), with the ability to normalize, compute distances, etc.. If I could do it using those methods instead of subtracting the coordinates each time.
If it can help, I need to know the position of A relative to B because A is supposed to push B, so if A it's on B's left, B needs to move right, etc...