Vector Length with Positive or Negative Direction

Hi all. I am trying to use vector length to give me a length of a vector but also tell me if the direction is in the positive or negative direction relative to my starting point and forward vector.

To better explain, I am setting the forward vector and the original location of an actor. When the actor moves, I would like to know if the actor is moving to the right of the original location based on the forward vector or to the left of the original location based on the forward vector. I am able to get the vector length from the original location to the new location but it always comes out positive. I assume this is because it is giving an absolute value. How do I get the direction (positive or negative) of the new location from the original?

Here is an illustration to show what I am talking about.

&stc=1

Take the angle between the positive direction and the displacement vector (i.e., the vector pointing from your original location to your current one). If it’s less than 90 degrees, you are on the “positive” side of the red arrow, otherwise you’re on the left.

Gur2iIE.png

Get the right vector of the orig position and use that for dotproduct to determine if the current position is on the right side of the orig position (positive) or the left side (negative).

pseudo code for 2d…
float Dir = DotProduct(right vector, (CurPosition - OrigPosition),GetSafeNormal());

if Dir is positive, means right .
if Dir is negative means left.

Using the dotproduct worked great! Thanks for the help. :slight_smile: