1

Here I have two vectors A and B, I want to determine in which direction does B face compared to A, so imagine A vector as screen devisor to two parts, left and right part and imagine B as just a 2D point in whichever left or right part, which part we don't know and thats what I want to determine. How do I go about doing that?

G.Azma
  • 37
  • 9
  • You can compute their [cross product](https://en.wikipedia.org/wiki/Cross_product) – Karen Baghdasaryan Aug 24 '21 at 13:20
  • Duplicate question: [How to know if point is on the right side or on the left side of line](https://stackoverflow.com/questions/68592435/how-to-know-if-point-is-on-the-right-side-or-on-the-left-side-of-line) – Stef Aug 24 '21 at 14:20
  • Hmm, I searched for this on the internet and could not find it, looking at that title, am convinced my googling skills are below average – G.Azma Aug 24 '21 at 15:19

1 Answers1

2

Calculate cross product of vectors A and B. Sign of result show direction of vector B relative to vector A

cross =  A.X * B.Y - A.Y * B.X
MBo
  • 77,366
  • 5
  • 53
  • 86
  • Also should be noted if the coordinate system in which the components are computed is whether right-handed or left-handed – Karen Baghdasaryan Aug 24 '21 at 13:21
  • Thank you so much, I asked this question because I was overcomplicating an answer, even if I got it, it would be too slow, thanks. – G.Azma Aug 24 '21 at 13:22
  • 1
    coordinate system is right-handed, but does not matter I will negate if it's incorrect (I will accept this answer in 8minutes, it's on cooldown) – G.Azma Aug 24 '21 at 13:24